1 |
wakaba |
1.1 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use Test; |
4 |
wakaba |
1.3 |
BEGIN { plan tests => 29 } |
5 |
wakaba |
1.1 |
|
6 |
|
|
require Message::DOM::DOMImplementation; |
7 |
|
|
use Message::Util::Error; |
8 |
|
|
|
9 |
|
|
my $dom = Message::DOM::DOMImplementation->____new; |
10 |
|
|
my $doc = $dom->create_document; |
11 |
|
|
|
12 |
|
|
## |isElementContentWhitespace| |
13 |
|
|
{ |
14 |
|
|
my $node = $doc->create_text_node (''); |
15 |
|
|
|
16 |
|
|
ok $node->is_element_content_whitespace ? 1 : 0, 0, 'ecw [0]'; |
17 |
|
|
|
18 |
|
|
$node->is_element_content_whitespace (1); |
19 |
|
|
ok $node->is_element_content_whitespace ? 1 : 0, 1, 'rcw [1]'; |
20 |
|
|
|
21 |
|
|
$node->is_element_content_whitespace (0); |
22 |
|
|
ok $node->is_element_content_whitespace ? 1 : 0, 0, 'ecw [2]'; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
## |wholeText| |
26 |
|
|
{ |
27 |
|
|
my $text1 = $doc->create_text_node ('text1'); |
28 |
|
|
my $el = $doc->create_element ('el'); |
29 |
|
|
$el->append_child ($text1); |
30 |
|
|
|
31 |
|
|
ok $text1->whole_text, 'text1', 'whole_text [1]'; |
32 |
|
|
|
33 |
|
|
my $text2 = $doc->create_text_node ('text2'); |
34 |
|
|
$el->append_child ($text2); |
35 |
|
|
|
36 |
|
|
ok $text1->whole_text, 'text1text2', 'whole_text [2]'; |
37 |
|
|
ok $text2->whole_text, 'text1text2', 'whole_text [3]'; |
38 |
|
|
|
39 |
|
|
my $text3 = $doc->create_cdata_section ('text3'); |
40 |
|
|
$el->append_child ($text3); |
41 |
|
|
|
42 |
|
|
ok $text1->whole_text, 'text1text2text3', 'whole_text [4]'; |
43 |
|
|
ok $text2->whole_text, 'text1text2text3', 'whole_text [5]'; |
44 |
|
|
ok $text3->whole_text, 'text1text2text3', 'whole_text [6]'; |
45 |
|
|
|
46 |
|
|
my $el1 = $doc->create_element ('el1'); |
47 |
|
|
$el->append_child ($el1); |
48 |
|
|
$el->append_child ($text2); |
49 |
|
|
|
50 |
|
|
ok $text1->whole_text, 'text1text3', 'whole_text [7]'; |
51 |
|
|
ok $text2->whole_text, 'text2', 'whole_text [8]'; |
52 |
|
|
ok $text3->whole_text, 'text1text3', 'whole_text [9]'; |
53 |
|
|
} |
54 |
|
|
{ |
55 |
|
|
my $el = $doc->create_element ('e'); |
56 |
|
|
my $text1 = $doc->create_text_node ('text1'); |
57 |
|
|
$el->append_child ($text1); |
58 |
|
|
my $text3 = $doc->create_cdata_section ('text3'); |
59 |
|
|
$el->append_child ($text3); |
60 |
|
|
my $er1 = $doc->create_entity_reference ('er1'); |
61 |
|
|
$er1->manakai_set_read_only (0, 1); |
62 |
|
|
$el->append_child ($er1); |
63 |
|
|
my $text4 = $doc->create_text_node ('text4'); |
64 |
|
|
$er1->append_child ($text4); |
65 |
|
|
my $text2 = $doc->create_cdata_section ('text2'); |
66 |
|
|
$el->append_child ($text2); |
67 |
|
|
|
68 |
|
|
ok $text1->whole_text, 'text1text3text4text2', 'whole_text [10]'; |
69 |
|
|
ok $text2->whole_text, 'text1text3text4text2', 'whole_text [11]'; |
70 |
|
|
ok $text3->whole_text, 'text1text3text4text2', 'whole_text [12]'; |
71 |
|
|
ok $text4->whole_text, 'text1text3text4text2', 'whole_text [13]'; |
72 |
|
|
} |
73 |
|
|
{ |
74 |
|
|
my $el = $doc->create_element ('e'); |
75 |
|
|
my $text1 = $doc->create_text_node ('text1'); |
76 |
|
|
$el->append_child ($text1); |
77 |
|
|
my $text3 = $doc->create_cdata_section ('text3'); |
78 |
|
|
$el->append_child ($text3); |
79 |
|
|
my $er1 = $doc->create_entity_reference ('er1'); |
80 |
|
|
$er1->manakai_set_read_only (0, 1); |
81 |
|
|
$el->append_child ($er1); |
82 |
|
|
my $text4 = $doc->create_text_node ('text4'); |
83 |
|
|
$er1->append_child ($text4); |
84 |
|
|
my $com1 = $doc->create_comment (''); |
85 |
|
|
$er1->append_child ($com1); |
86 |
|
|
my $text2 = $doc->create_text_node ('text2'); |
87 |
|
|
$el->append_child ($text2); |
88 |
|
|
|
89 |
|
|
ok $text1->whole_text, 'text1text3text4', 'whole_text [14]'; |
90 |
|
|
ok $text2->whole_text, 'text2', 'whole_text [15]'; |
91 |
|
|
ok $text3->whole_text, 'text1text3text4', 'whole_text [16]'; |
92 |
|
|
ok $text4->whole_text, 'text1text3text4', 'whole_text [17]'; |
93 |
|
|
} |
94 |
|
|
|
95 |
wakaba |
1.2 |
## |CDATASection| |splitText| |
96 |
|
|
{ |
97 |
|
|
my $node = $doc->create_cdata_section ('abcdefg'); |
98 |
|
|
|
99 |
|
|
my $return = $node->split_text (3); |
100 |
|
|
|
101 |
|
|
ok $node->node_value, 'abc', 'split_text A [1]'; |
102 |
|
|
ok $return->node_type, 4, 'split_text B.node_type [1]'; |
103 |
|
|
ok $return->node_value, 'defg', 'split_text B [1]'; |
104 |
|
|
ok $return->parent_node, undef, 'split_text B.parent_node [1]'; |
105 |
|
|
|
106 |
|
|
$node->node_value ('abcdefg'); |
107 |
|
|
my $el = $doc->create_element ('e'); |
108 |
|
|
$el->append_child ($node); |
109 |
|
|
|
110 |
|
|
$return = $node->split_text (3); |
111 |
|
|
|
112 |
|
|
ok $node->node_value, 'abc', 'split_text A [2]'; |
113 |
|
|
ok $return->node_type, 4, 'split_text B.node_type [2]'; |
114 |
|
|
ok $return->node_value, 'defg', 'split_text B [2]'; |
115 |
|
|
ok $return->parent_node, $el, 'split_text B.parent_node [2]'; |
116 |
|
|
ok $return->previous_sibling, $node, 'split_text B.ps [2]'; |
117 |
|
|
} |
118 |
|
|
|
119 |
wakaba |
1.1 |
=head1 LICENSE |
120 |
|
|
|
121 |
|
|
Copyright 2007 Wakaba <w@suika.fam.cx> |
122 |
|
|
|
123 |
|
|
This program is free software; you can redistribute it and/or |
124 |
|
|
modify it under the same terms as Perl itself. |
125 |
|
|
|
126 |
|
|
=cut |
127 |
|
|
|
128 |
wakaba |
1.3 |
## $Date: 2007/07/14 10:28:52 $ |