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

Contents of /messaging/manakai/t/DOM-Text.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download) (as text)
Sat Jul 14 16:32:28 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-4-0, HEAD
Changes since 1.2: +2 -2 lines
File MIME type: application/x-troff
++ manakai/t/ChangeLog	14 Jul 2007 16:32:13 -0000
2007-07-15  Wakaba  <wakaba@suika.fam.cx>

	* DOM-TreeWalker.t, DOM-SerialWalker.t: New test scripts.

	* DOM-DOMImplementation.t: Tests for |Traversal| feature
	are added.

	* DOM-Node.t: Tests for |Traversal| feature are added.

++ manakai/lib/Message/DOM/ChangeLog	14 Jul 2007 16:31:23 -0000
2007-07-15  Wakaba  <wakaba@suika.fam.cx>

	* TreeWalker.pm, SerialWalker.pm: New Perl modules.

	* Text.pm (whole_text): Parameter index number has
	been changed to support new |NodeFilter| Perl binding
	definition.

2007-07-14  Wakaba  <wakaba@suika.fam.cx>

	* AttributeDefinition.pm, DOMElement.pm, DocumentType.pm,
	ElementTypeDefinition.pm, Entity.pm, EntityReference.pm,
	Notation.pm, ProcessingInstruction.pm (AUTOLOAD): Don't croak even if an attempt is made to modify a read-only attribute.

	* DOMConfiguration.pm (can_set_parameter,
	set_parameter): Don't allow to set the value
	to a string other than <http://www.w3.org/TR/REC-xml> (XML 1.0 DTD).

	* DOMDocument.pm (Message::IF::DocumentTraversal): New interface.
	(create_tree_walker, manakai_create_serial_walker): References
	and prototypes are added.

	* DOMException.pm (NULLPO_ERR): New error type:-).

	* DOMImplementation.pm ($HasFeature): Feature |Traversal|,
	version |2.0|, is added.

1 #!/usr/bin/perl
2 use strict;
3 use Test;
4 BEGIN { plan tests => 29 }
5
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 ## |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 =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 ## $Date: 2007/07/14 10:28:52 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24