1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
2 |
use strict; |
use strict; |
3 |
use Test; |
use Test; |
4 |
BEGIN { plan tests => 4693 } |
BEGIN { plan tests => 4918 } |
5 |
|
|
6 |
require Message::DOM::DOMImplementation; |
require Message::DOM::DOMImplementation; |
7 |
use Message::Util::Error; |
use Message::Util::Error; |
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], |
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', |
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', |
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', |
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 |