/[suikacvs]/messaging/manakai/t/DOM-Node.t
Suika

Diff of /messaging/manakai/t/DOM-Node.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by wakaba, Sun Jul 8 13:04:39 2007 UTC revision 1.17 by wakaba, Sat Jul 14 10:28:52 2007 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl
2  use strict;  use strict;
3  use Test;  use Test;
4  BEGIN { plan tests => 4429 }  BEGIN { plan tests => 4918 }
5    
6  require Message::DOM::DOMImplementation;  require Message::DOM::DOMImplementation;
7  use Message::Util::Error;  use Message::Util::Error;
# Line 42  sub create_parent_nodes () { Line 42  sub create_parent_nodes () {
42    );    );
43  } # create_parent_nodes  } # create_parent_nodes
44    
45    sub create_leaf_nodes () {
46      (
47       $doc->create_cdata_section ('cdata1'),
48       $doc->create_comment ('comment1'),
49       $doc->create_notation ('notation1'),
50       $doc->create_processing_instruction ('pi1', 'pi1data'),
51       $doc->create_text_node ('text1'),
52      );
53    } # create_leaf_nodes
54    
55  ## Constants  ## Constants
56  my $constants = [  my $constants = [
57    [ELEMENT_NODE => 1],    [ELEMENT_NODE => 1],
# Line 65  my $constants = [ Line 75  my $constants = [
75    [DOCUMENT_POSITION_CONTAINS => 0x08],    [DOCUMENT_POSITION_CONTAINS => 0x08],
76    [DOCUMENT_POSITION_CONTAINED_BY => 0x10],    [DOCUMENT_POSITION_CONTAINED_BY => 0x10],
77    [DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC => 0x20],    [DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC => 0x20],
78    
79      [NODE_CLONED => 1],
80      [NODE_IMPORTED => 2],
81      [NODE_DELETED => 3],
82      [NODE_RENAMED => 4],
83      [NODE_ADOPTED => 5],
84  ];  ];
85    
86  my $tests = {  my $tests = {
# Line 94  my $tests = { Line 110  my $tests = {
110      attr_get_bool => {      attr_get_bool => {
111        has_attributes => 0,        has_attributes => 0,
112        has_child_nodes => 0,        has_child_nodes => 0,
113          is_id => 0,
114        manakai_read_only => 0,        manakai_read_only => 0,
115        specified => 1,        specified => 1,
116      },      },
# Line 126  my $tests = { Line 143  my $tests = {
143      attr_get_bool => {      attr_get_bool => {
144        has_attributes => 0,        has_attributes => 0,
145        has_child_nodes => 1,        has_child_nodes => 1,
146          is_id => 0,
147        manakai_read_only => 0,        manakai_read_only => 0,
148        specified => 1,        specified => 1,
149      },      },
# Line 153  my $tests = { Line 171  my $tests = {
171      attr_get_bool => {      attr_get_bool => {
172        has_attributes => 0,        has_attributes => 0,
173        has_child_nodes => 0,        has_child_nodes => 0,
174          is_id => 0,
175        manakai_read_only => 0,        manakai_read_only => 0,
176        specified => 1,        specified => 1,
177      },      },
# Line 180  my $tests = { Line 199  my $tests = {
199      attr_get_bool => {      attr_get_bool => {
200        has_attributes => 0,        has_attributes => 0,
201        has_child_nodes => 0,        has_child_nodes => 0,
202          is_id => 0,
203        manakai_read_only => 0,        manakai_read_only => 0,
204        specified => 1,        specified => 1,
205      },      },
# Line 207  my $tests = { Line 227  my $tests = {
227      attr_get_bool => {      attr_get_bool => {
228        has_attributes => 0,        has_attributes => 0,
229        has_child_nodes => 0,        has_child_nodes => 0,
230          is_id => 0,
231        manakai_read_only => 0,        manakai_read_only => 0,
232        specified => 1,        specified => 1,
233      },      },
# Line 410  my $tests = { Line 431  my $tests = {
431      },      },
432    },    },
433    document_type => {    document_type => {
434      node => sub { return $doc->implementation->create_document_type ('n') },      node => sub {
435          return $doc->implementation->create_document_type ('n', '', '');
436        },
437      attr_get => {      attr_get => {
438        attributes => undef,        attributes => undef,
439        base_uri => undef,        base_uri => undef,
# Line 419  my $tests = { Line 442  my $tests = {
442        manakai_expanded_uri => undef,        manakai_expanded_uri => undef,
443        first_child => undef,        first_child => undef,
444        implementation => $dom,        implementation => $dom,
445          internal_subset => '',
446        last_child => undef,        last_child => undef,
447        local_name => undef,        local_name => undef,
448        manakai_local_name => undef,        manakai_local_name => undef,
# Line 431  my $tests = { Line 455  my $tests = {
455        parent_node => undef,        parent_node => undef,
456        prefix => undef,        prefix => undef,
457        previous_sibling => undef,        previous_sibling => undef,
458        public_id => undef,        public_id => '',
459        system_id => undef,        system_id => '',
460      },      },
461      attr_get_bool => {      attr_get_bool => {
462        has_attributes => 0,        has_attributes => 0,
# Line 450  my $tests = { Line 474  my $tests = {
474        manakai_expanded_uri => undef,        manakai_expanded_uri => undef,
475        first_child => undef,        first_child => undef,
476        implementation => $dom,        implementation => $dom,
477          internal_subset => '',
478        last_child => undef,        last_child => undef,
479        local_name => undef,        local_name => undef,
480        manakai_local_name => undef,        manakai_local_name => undef,
# Line 462  my $tests = { Line 487  my $tests = {
487        parent_node => undef,        parent_node => undef,
488        prefix => undef,        prefix => undef,
489        previous_sibling => undef,        previous_sibling => undef,
490        public_id => undef,        public_id => '',
491        system_id => undef,        system_id => '',
492      },      },
493      attr_get_bool => {      attr_get_bool => {
494        has_attributes => 0,        has_attributes => 0,
# Line 474  my $tests = { Line 499  my $tests = {
499    element => {    element => {
500      node => sub { return $doc->create_element ('e') },      node => sub { return $doc->create_element ('e') },
501      attr_get => {      attr_get => {
       ## TODO: attributes =>  
502        base_uri => undef,        base_uri => undef,
503        manakai_base_uri => undef,        manakai_base_uri => undef,
504        manakai_expanded_uri => 'e',        manakai_expanded_uri => 'e',
# Line 502  my $tests = { Line 526  my $tests = {
526    element_ns_default => {    element_ns_default => {
527      node => sub { return $doc->create_element_ns ('http://test/', 'f') },      node => sub { return $doc->create_element_ns ('http://test/', 'f') },
528      attr_get => {      attr_get => {
       ## TODO: attributes =>  
529        base_uri => undef,        base_uri => undef,
530        manakai_base_uri => undef,        manakai_base_uri => undef,
531        manakai_expanded_uri => 'http://test/f',        manakai_expanded_uri => 'http://test/f',
# Line 530  my $tests = { Line 553  my $tests = {
553    element_ns_prefiexed => {    element_ns_prefiexed => {
554      node => sub { return $doc->create_element_ns ('http://test/', 'e:f') },      node => sub { return $doc->create_element_ns ('http://test/', 'e:f') },
555      attr_get => {      attr_get => {
       ## TODO: attributes =>  
556        base_uri => undef,        base_uri => undef,
557        manakai_base_uri => undef,        manakai_base_uri => undef,
558        manakai_expanded_uri => 'http://test/f',        manakai_expanded_uri => 'http://test/f',
# Line 572  my $tests = { Line 594  my $tests = {
594        node_value => undef,        node_value => undef,
595        notation_name => undef,        notation_name => undef,
596        owner_document => $doc,        owner_document => $doc,
597          owner_document_type_definition => undef,
598        parent_node => undef,        parent_node => undef,
599        previous_sibling => undef,        previous_sibling => undef,
600        public_id => undef,        public_id => undef,
# Line 629  my $tests = { Line 652  my $tests = {
652        node_type => 12,        node_type => 12,
653        node_value => undef,        node_value => undef,
654        owner_document => $doc,        owner_document => $doc,
655          owner_document_type_definition => undef,
656        parent_node => undef,        parent_node => undef,
657        prefix => undef,        prefix => undef,
658        previous_sibling => undef,        previous_sibling => undef,
# Line 711  my $tests = { Line 735  my $tests = {
735        node_type => 81001,        node_type => 81001,
736        node_value => undef,        node_value => undef,
737        owner_document => $doc,        owner_document => $doc,
738          owner_document_type_definition => undef,
739        parent_node => undef,        parent_node => undef,
740        prefix => undef,        prefix => undef,
741        previous_sibling => undef,        previous_sibling => undef,
# Line 737  my $tests = { Line 762  my $tests = {
762        next_sibling => undef,        next_sibling => undef,
763        node_name => 'e',        node_name => 'e',
764        node_type => 81002,        node_type => 81002,
765        node_value => undef,        node_value => '',
766        owner_document => $doc,        owner_document => $doc,
767          owner_element_type_definition => undef,
768        parent_node => undef,        parent_node => undef,
769        prefix => undef,        prefix => undef,
770        previous_sibling => undef,        previous_sibling => undef,
771          text_content => '',
772      },      },
773      attr_get_bool => {      attr_get_bool => {
774        has_attributes => 0,        has_attributes => 0,
# Line 1243  for my $i (0..1) { Line 1270  for my $i (0..1) {
1270             ]->[$i];             ]->[$i];
1271    
1272    my $doc2 = $doc->implementation->create_document;    my $doc2 = $doc->implementation->create_document;
1273      $doc2->strict_error_checking (0);
1274        
1275    my $el = $doc2->create_element_ns (undef, 'el');    my $el = $doc2->create_element_ns (undef, 'el');
1276    
# Line 1951  for my $node (create_nodes ()) { Line 1979  for my $node (create_nodes ()) {
1979    ok 0+@{$el->child_nodes}, 0, 'Node->remove_child child_nodes [4]';    ok 0+@{$el->child_nodes}, 0, 'Node->remove_child child_nodes [4]';
1980  }  }
1981    
1982    ## |appendChild|, |insertBefore|, |replaceChild|
1983    for my $node (create_leaf_nodes) {
1984      for my $method_name (qw/append_child insert_before replace_child/) {
1985        ok $node->can ($method_name) ? 1 : 0, 1,
1986            $node->node_name . '->can ' . $method_name;
1987    
1988        for my $node2 (create_nodes) {
1989          try {
1990            if ($method_name eq 'replace_child') {
1991              $node->replace_child ($node2, $node2);
1992            } else {
1993              $node->$method_name ($node2);
1994            }
1995            ok 1, 0,
1996                $node->node_name . '->' . $method_name . ' ' . $node2->node_name;
1997          } catch Message::IF::DOMException with {
1998            if ($_[0]->type eq 'HIERARCHY_REQUEST_ERR' or
1999                ($_[0]->type eq 'WRONG_DOCUMENT_ERR' and
2000                 ($node2->owner_document or $node2) ne $doc) or
2001                ($_[0]->type eq 'NOT_FOUND_ERR' and
2002                 $method_name eq 'replace_child')) {
2003              ok 1, 1,
2004                $node->node_name . '->' . $method_name . ' ' . $node2->node_name;
2005            }
2006          };
2007        }
2008      }
2009    }
2010    
2011  ## TODO: parent_node tests, as with append_child tests  ## TODO: parent_node tests, as with append_child tests
2012    
2013  ## TODO: text_content tests for CharacterData and PI  ## TODO: text_content tests for CharacterData and PI

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.17

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24