/[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.5 by wakaba, Sun Jun 17 14:15:39 2007 UTC revision 1.8 by wakaba, Sat Jul 7 09:11:05 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 => 1921 }  BEGIN { plan tests => 2754 }
5    
6  require Message::DOM::DOMImplementation;  require Message::DOM::DOMImplementation;
7  use Message::Util::Error;  use Message::Util::Error;
# Line 58  my $constants = [ Line 58  my $constants = [
58    [NOTATION_NODE => 12],    [NOTATION_NODE => 12],
59    [ELEMENT_TYPE_DEFINITION_NODE => 81001],    [ELEMENT_TYPE_DEFINITION_NODE => 81001],
60    [ATTRIBUTE_DEFINITION_NODE => 81002],    [ATTRIBUTE_DEFINITION_NODE => 81002],
61    
62      [DOCUMENT_POSITION_DISCONNECTED => 0x01],
63      [DOCUMENT_POSITION_PRECEDING => 0x02],
64      [DOCUMENT_POSITION_FOLLOWING => 0x04],
65      [DOCUMENT_POSITION_CONTAINS => 0x08],
66      [DOCUMENT_POSITION_CONTAINED_BY => 0x10],
67      [DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC => 0x20],
68  ];  ];
69    
70  my $tests = {  my $tests = {
# Line 66  my $tests = { Line 73  my $tests = {
73      attr_get => {      attr_get => {
74        manakai_attribute_type => 0,        manakai_attribute_type => 0,
75        base_uri => undef,        base_uri => undef,
76          manakai_expanded_uri => 'a',
77        first_child => undef,        first_child => undef,
78        last_child => undef,        last_child => undef,
79        local_name => 'a',        local_name => 'a',
# Line 73  my $tests = { Line 81  my $tests = {
81        namespace_uri => undef,        namespace_uri => undef,
82        next_sibling => undef,        next_sibling => undef,
83        node_name => 'a',        node_name => 'a',
84          node_type => 2,
85        name => 'a',        name => 'a',
86        node_value => '',        node_value => '',
87        owner_document => $doc,        owner_document => $doc,
# Line 83  my $tests = { Line 92  my $tests = {
92        attributes => undef,        attributes => undef,
93      },      },
94      attr_get_bool => {      attr_get_bool => {
95          has_attributes => 0,
96          has_child_nodes => 0,
97        specified => 1,        specified => 1,
98      },      },
99    },    },
# Line 95  my $tests = { Line 106  my $tests = {
106      attr_get => {      attr_get => {
107        manakai_attribute_type => 0,        manakai_attribute_type => 0,
108        base_uri => undef,        base_uri => undef,
109          manakai_expanded_uri => 'a',
110        local_name => 'a',        local_name => 'a',
111        manakai_local_name => 'a',        manakai_local_name => 'a',
112        namespace_uri => undef,        namespace_uri => undef,
113        next_sibling => undef,        next_sibling => undef,
114        node_name => 'a',        node_name => 'a',
115          node_type => 2,
116        name => 'a',        name => 'a',
117        node_value => 'b',        node_value => 'b',
118        owner_document => $doc,        owner_document => $doc,
# Line 110  my $tests = { Line 123  my $tests = {
123        attributes => undef,        attributes => undef,
124      },      },
125      attr_get_bool => {      attr_get_bool => {
126          has_attributes => 0,
127          has_child_nodes => 1,
128        specified => 1,        specified => 1,
129      },      },
130    },    },
# Line 117  my $tests = { Line 132  my $tests = {
132      node => sub { return $doc->create_attribute_ns (undef, 'a') },      node => sub { return $doc->create_attribute_ns (undef, 'a') },
133      attr_get => {      attr_get => {
134        base_uri => undef,        base_uri => undef,
135          manakai_expanded_uri => 'a',
136        local_name => 'a',        local_name => 'a',
137        manakai_local_name => 'a',        manakai_local_name => 'a',
138        namespace_uri => undef,        namespace_uri => undef,
139        next_sibling => undef,        next_sibling => undef,
140        node_name => 'a',        node_name => 'a',
141          node_type => 2,
142        name => 'a',        name => 'a',
143        node_value => '',        node_value => '',
144        owner_document => $doc,        owner_document => $doc,
# Line 131  my $tests = { Line 148  my $tests = {
148        attributes => undef,        attributes => undef,
149        previous_sibling => undef,        previous_sibling => undef,
150      },      },
151        attr_get_bool => {
152          has_attributes => 0,
153          has_child_nodes => 0,
154          specified => 1,
155        },
156    },    },
157    attr_ns_prefixed => {    attr_ns_prefixed => {
158      node => sub { return $doc->create_attribute_ns ('http://test/', 'a:b') },      node => sub { return $doc->create_attribute_ns ('http://test/', 'a:b') },
159      attr_get => {      attr_get => {
160        base_uri => undef,        base_uri => undef,
161          manakai_expanded_uri => 'http://test/b',
162        local_name => 'b',        local_name => 'b',
163        manakai_local_name => 'b',        manakai_local_name => 'b',
164        namespace_uri => 'http://test/',        namespace_uri => 'http://test/',
165        next_sibling => undef,        next_sibling => undef,
166        node_name => 'a:b',        node_name => 'a:b',
167          node_type => 2,
168        name => 'a:b',        name => 'a:b',
169        node_value => '',        node_value => '',
170        owner_document => $doc,        owner_document => $doc,
# Line 150  my $tests = { Line 174  my $tests = {
174        attributes => undef,        attributes => undef,
175        previous_sibling => undef,        previous_sibling => undef,
176      },      },
177        attr_get_bool => {
178          has_attributes => 0,
179          has_child_nodes => 0,
180          specified => 1,
181        },
182      },
183      attr_ns_prefixed_array => {
184        node => sub { $doc->create_attribute_ns ('http://test/', ['a', 'b']) },
185        attr_get => {
186          base_uri => undef,
187          manakai_expanded_uri => 'http://test/b',
188          local_name => 'b',
189          manakai_local_name => 'b',
190          namespace_uri => 'http://test/',
191          next_sibling => undef,
192          node_name => 'a:b',
193          node_type => 2,
194          name => 'a:b',
195          node_value => '',
196          owner_document => $doc,
197          parent_node => undef,
198          prefix => 'a',
199          value => '',
200          attributes => undef,
201          previous_sibling => undef,
202        },
203        attr_get_bool => {
204          has_attributes => 0,
205          has_child_nodes => 0,
206          specified => 1,
207        },
208    },    },
209    cdatasection => {    cdatasection => {
210      node => sub { return $doc->create_cdata_section ('cdatadata') },      node => sub { return $doc->create_cdata_section ('cdatadata') },
211      attr_get => {      attr_get => {
212        base_uri => undef,        base_uri => undef,
213          manakai_expanded_uri => undef,
214        first_child => undef,        first_child => undef,
215        last_child => undef,        last_child => undef,
216        local_name => undef,        local_name => undef,
# Line 162  my $tests = { Line 218  my $tests = {
218        namespace_uri => undef,        namespace_uri => undef,
219        next_sibling => undef,        next_sibling => undef,
220        node_name => '#cdata-section',        node_name => '#cdata-section',
221          node_type => 4,
222        node_value => 'cdatadata',        node_value => 'cdatadata',
223        owner_document => $doc,        owner_document => $doc,
224        parent_node => undef,        parent_node => undef,
# Line 170  my $tests = { Line 227  my $tests = {
227        attributes => undef,        attributes => undef,
228        previous_sibling => undef,        previous_sibling => undef,
229      },      },
230        attr_get_bool => {
231          has_attributes => 0,
232          has_child_nodes => 0,
233        },
234    },    },
235    cdatasectionmde => {    cdatasectionmde => {
236      node => sub { return $doc->create_cdata_section ('cdata]]>data') },      node => sub { return $doc->create_cdata_section ('cdata]]>data') },
237      attr_get => {      attr_get => {
238        base_uri => undef,        base_uri => undef,
239          manakai_expanded_uri => undef,
240        first_child => undef,        first_child => undef,
241        last_child => undef,        last_child => undef,
242        local_name => undef,        local_name => undef,
# Line 182  my $tests = { Line 244  my $tests = {
244        namespace_uri => undef,        namespace_uri => undef,
245        next_sibling => undef,        next_sibling => undef,
246        node_name => '#cdata-section',        node_name => '#cdata-section',
247          node_type => 4,
248        node_value => 'cdata]]>data',        node_value => 'cdata]]>data',
249        owner_document => $doc,        owner_document => $doc,
250        parent_node => undef,        parent_node => undef,
# Line 190  my $tests = { Line 253  my $tests = {
253        attributes => undef,        attributes => undef,
254        previous_sibling => undef,        previous_sibling => undef,
255      },      },
256        attr_get_bool => {
257          has_attributes => 0,
258          has_child_nodes => 0,
259        },
260    },    },
261    comment => {    comment => {
262      node => sub { return $doc->create_comment ('commentdata') },      node => sub { return $doc->create_comment ('commentdata') },
263      attr_get => {      attr_get => {
264        base_uri => undef,        base_uri => undef,
265          manakai_expanded_uri => undef,
266        first_child => undef,        first_child => undef,
267        last_child => undef,        last_child => undef,
268        local_name => undef,        local_name => undef,
# Line 202  my $tests = { Line 270  my $tests = {
270        namespace_uri => undef,        namespace_uri => undef,
271        next_sibling => undef,        next_sibling => undef,
272        node_name => '#comment',        node_name => '#comment',
273          node_type => 8,
274        node_value => 'commentdata',        node_value => 'commentdata',
275        owner_document => $doc,        owner_document => $doc,
276        parent_node => undef,        parent_node => undef,
# Line 209  my $tests = { Line 278  my $tests = {
278        data => 'commentdata',        data => 'commentdata',
279        attributes => undef,        attributes => undef,
280        previous_sibling => undef,        previous_sibling => undef,
281        },
282        attr_get_bool => {
283          has_attributes => 0,
284          has_child_nodes => 0,
285      },      },
286    },    },
287    commentcom1 => {    commentcom1 => {
288      node => sub { return $doc->create_comment ('comment--data') },      node => sub { return $doc->create_comment ('comment--data') },
289      attr_get => {      attr_get => {
290        base_uri => undef,        base_uri => undef,
291          manakai_expanded_uri => undef,
292        first_child => undef,        first_child => undef,
293        last_child => undef,        last_child => undef,
294        local_name => undef,        local_name => undef,
# Line 222  my $tests = { Line 296  my $tests = {
296        namespace_uri => undef,        namespace_uri => undef,
297        next_sibling => undef,        next_sibling => undef,
298        node_name => '#comment',        node_name => '#comment',
299          node_type => 8,
300        node_value => 'comment--data',        node_value => 'comment--data',
301        owner_document => $doc,        owner_document => $doc,
302        parent_node => undef,        parent_node => undef,
# Line 230  my $tests = { Line 305  my $tests = {
305        attributes => undef,        attributes => undef,
306        previous_sibling => undef,        previous_sibling => undef,
307      },      },
308        attr_get_bool => {
309          has_attributes => 0,
310          has_child_nodes => 0,
311        },
312    },    },
313    commentcom2 => {    commentcom2 => {
314      node => sub { return $doc->create_comment ('commentdata-') },      node => sub { return $doc->create_comment ('commentdata-') },
315      attr_get => {      attr_get => {
316        base_uri => undef,        base_uri => undef,
317          manakai_expanded_uri => undef,
318        first_child => undef,        first_child => undef,
319        last_child => undef,        last_child => undef,
320        local_name => undef,        local_name => undef,
# Line 242  my $tests = { Line 322  my $tests = {
322        namespace_uri => undef,        namespace_uri => undef,
323        next_sibling => undef,        next_sibling => undef,
324        node_name => '#comment',        node_name => '#comment',
325          node_type => 8,
326        node_value => 'commentdata-',        node_value => 'commentdata-',
327        owner_document => $doc,        owner_document => $doc,
328        parent_node => undef,        parent_node => undef,
# Line 250  my $tests = { Line 331  my $tests = {
331        attributes => undef,        attributes => undef,
332        previous_sibling => undef,        previous_sibling => undef,
333      },      },
334        attr_get_bool => {
335          has_attributes => 0,
336          has_child_nodes => 0,
337        },
338    },    },
339    document => {    document => {
340      node => sub { return $doc },      node => sub { return $doc },
# Line 258  my $tests = { Line 343  my $tests = {
343        base_uri => undef,        base_uri => undef,
344        document_uri => undef,        document_uri => undef,
345        manakai_entity_base_uri => undef,        manakai_entity_base_uri => undef,
346          manakai_expanded_uri => undef,
347        first_child => undef,        first_child => undef,
348        implementation => $dom,        implementation => $dom,
349        last_child => undef,        last_child => undef,
# Line 266  my $tests = { Line 352  my $tests = {
352        namespace_uri => undef,        namespace_uri => undef,
353        next_sibling => undef,        next_sibling => undef,
354        node_name => '#document',        node_name => '#document',
355          node_type => 9,
356        node_value => undef,        node_value => undef,
357        owner_document => undef,        owner_document => undef,
358        parent_node => undef,        parent_node => undef,
# Line 276  my $tests = { Line 363  my $tests = {
363      },      },
364      attr_get_bool => {      attr_get_bool => {
365        all_declarations_processed => 0,        all_declarations_processed => 0,
366          has_attributes => 0,
367          has_child_nodes => 0,
368        manakai_is_html => 0,        manakai_is_html => 0,
369        strict_error_checking => 1,        strict_error_checking => 1,
370        xml_standalone => 0,        xml_standalone => 0,
# Line 286  my $tests = { Line 375  my $tests = {
375      attr_get => {      attr_get => {
376        attributes => undef,        attributes => undef,
377        base_uri => undef,        base_uri => undef,
378          manakai_expanded_uri => undef,
379        first_child => undef,        first_child => undef,
380        last_child => undef,        last_child => undef,
381        local_name => undef,        local_name => undef,
# Line 293  my $tests = { Line 383  my $tests = {
383        namespace_uri => undef,        namespace_uri => undef,
384        next_sibling => undef,        next_sibling => undef,
385        node_name => '#document-fragment',        node_name => '#document-fragment',
386          node_type => 11,
387        node_value => undef,        node_value => undef,
388        owner_document => $doc,        owner_document => $doc,
389        parent_node => undef,        parent_node => undef,
390        prefix => undef,        prefix => undef,
391        previous_sibling => undef,        previous_sibling => undef,
392      },      },
393        attr_get_bool => {
394          has_attributes => 0,
395          has_child_nodes => 0,
396        },
397    },    },
398    document_type => {    document_type => {
399      node => sub { return $doc->implementation->create_document_type ('n') },      node => sub { return $doc->implementation->create_document_type ('n') },
# Line 307  my $tests = { Line 402  my $tests = {
402        base_uri => undef,        base_uri => undef,
403        declaration_base_uri => undef,        declaration_base_uri => undef,
404        manakai_declaration_base_uri => undef,        manakai_declaration_base_uri => undef,
405          manakai_expanded_uri => undef,
406        first_child => undef,        first_child => undef,
407        implementation => $dom,        implementation => $dom,
408        last_child => undef,        last_child => undef,
# Line 315  my $tests = { Line 411  my $tests = {
411        namespace_uri => undef,        namespace_uri => undef,
412        next_sibling => undef,        next_sibling => undef,
413        node_name => 'n',        node_name => 'n',
414          node_type => 10,
415        node_value => undef,        node_value => undef,
416        owner_document => undef,        owner_document => undef,
417        parent_node => undef,        parent_node => undef,
# Line 323  my $tests = { Line 420  my $tests = {
420        public_id => undef,        public_id => undef,
421        system_id => undef,        system_id => undef,
422      },      },
423        attr_get_bool => {
424          has_attributes => 0,
425          has_child_nodes => 0,
426        },
427    },    },
428    document_type_definition => {    document_type_definition => {
429      node => sub { return $doc->create_document_type_definition ('n') },      node => sub { return $doc->create_document_type_definition ('n') },
# Line 331  my $tests = { Line 432  my $tests = {
432        base_uri => undef,        base_uri => undef,
433        declaration_base_uri => undef,        declaration_base_uri => undef,
434        manakai_declaration_base_uri => undef,        manakai_declaration_base_uri => undef,
435          manakai_expanded_uri => undef,
436        first_child => undef,        first_child => undef,
437        implementation => $dom,        implementation => $dom,
438        last_child => undef,        last_child => undef,
# Line 339  my $tests = { Line 441  my $tests = {
441        namespace_uri => undef,        namespace_uri => undef,
442        next_sibling => undef,        next_sibling => undef,
443        node_name => 'n',        node_name => 'n',
444          node_type => 10,
445        node_value => undef,        node_value => undef,
446        owner_document => $doc,        owner_document => $doc,
447        parent_node => undef,        parent_node => undef,
# Line 347  my $tests = { Line 450  my $tests = {
450        public_id => undef,        public_id => undef,
451        system_id => undef,        system_id => undef,
452      },      },
453        attr_get_bool => {
454          has_attributes => 0,
455          has_child_nodes => 0,
456        },
457    },    },
458    element => {    element => {
459      node => sub { return $doc->create_element ('e') },      node => sub { return $doc->create_element ('e') },
# Line 354  my $tests = { Line 461  my $tests = {
461        ## TODO: attributes =>        ## TODO: attributes =>
462        base_uri => undef,        base_uri => undef,
463        manakai_base_uri => undef,        manakai_base_uri => undef,
464          manakai_expanded_uri => 'e',
465        first_child => undef,        first_child => undef,
466        last_child => undef,        last_child => undef,
467        local_name => 'e',        local_name => 'e',
# Line 361  my $tests = { Line 469  my $tests = {
469        namespace_uri => undef,        namespace_uri => undef,
470        next_sibling => undef,        next_sibling => undef,
471        node_name => 'e',        node_name => 'e',
472          node_type => 1,
473        node_value => undef,        node_value => undef,
474        owner_document => $doc,        owner_document => $doc,
475        parent_node => undef,        parent_node => undef,
476        prefix => undef,        prefix => undef,
477        previous_sibling => undef,        previous_sibling => undef,
478      },      },
479        attr_get_bool => {
480          has_attributes => 0,
481          has_child_nodes => 0,
482        },
483    },    },
484    element_ns_default => {    element_ns_default => {
485      node => sub { return $doc->create_element_ns ('http://test/', 'f') },      node => sub { return $doc->create_element_ns ('http://test/', 'f') },
# Line 374  my $tests = { Line 487  my $tests = {
487        ## TODO: attributes =>        ## TODO: attributes =>
488        base_uri => undef,        base_uri => undef,
489        manakai_base_uri => undef,        manakai_base_uri => undef,
490          manakai_expanded_uri => 'http://test/f',
491        first_child => undef,        first_child => undef,
492        last_child => undef,        last_child => undef,
493        local_name => 'f',        local_name => 'f',
# Line 381  my $tests = { Line 495  my $tests = {
495        namespace_uri => 'http://test/',        namespace_uri => 'http://test/',
496        next_sibling => undef,        next_sibling => undef,
497        node_name => 'f',        node_name => 'f',
498          node_type => 1,
499        node_value => undef,        node_value => undef,
500        owner_document => $doc,        owner_document => $doc,
501        parent_node => undef,        parent_node => undef,
502        prefix => undef,        prefix => undef,
503        previous_sibling => undef,        previous_sibling => undef,
504      },      },
505        attr_get_bool => {
506          has_attributes => 0,
507          has_child_nodes => 0,
508        },
509    },    },
510    element_ns_prefiexed => {    element_ns_prefiexed => {
511      node => sub { return $doc->create_element_ns ('http://test/', 'e:f') },      node => sub { return $doc->create_element_ns ('http://test/', 'e:f') },
# Line 394  my $tests = { Line 513  my $tests = {
513        ## TODO: attributes =>        ## TODO: attributes =>
514        base_uri => undef,        base_uri => undef,
515        manakai_base_uri => undef,        manakai_base_uri => undef,
516          manakai_expanded_uri => 'http://test/f',
517        first_child => undef,        first_child => undef,
518        last_child => undef,        last_child => undef,
519        local_name => 'f',        local_name => 'f',
# Line 401  my $tests = { Line 521  my $tests = {
521        namespace_uri => 'http://test/',        namespace_uri => 'http://test/',
522        next_sibling => undef,        next_sibling => undef,
523        node_name => 'e:f',        node_name => 'e:f',
524          node_type => 1,
525        node_value => undef,        node_value => undef,
526        owner_document => $doc,        owner_document => $doc,
527        parent_node => undef,        parent_node => undef,
528        prefix => 'e',        prefix => 'e',
529        previous_sibling => undef,        previous_sibling => undef,
530      },      },
531        attr_get_bool => {
532          has_attributes => 0,
533          has_child_nodes => 0,
534        },
535    },    },
536    entity => {    entity => {
537      node => sub { return $doc->create_general_entity ('e') },      node => sub { return $doc->create_general_entity ('e') },
# Line 416  my $tests = { Line 541  my $tests = {
541        manakai_declaration_base_uri => undef,        manakai_declaration_base_uri => undef,
542        manakai_entity_base_uri => undef,        manakai_entity_base_uri => undef,
543        manakai_entity_uri => undef,        manakai_entity_uri => undef,
544          manakai_expanded_uri => undef,
545        first_child => undef,        first_child => undef,
546        last_child => undef,        last_child => undef,
547        next_sibling => undef,        next_sibling => undef,
548        node_name => 'e',        node_name => 'e',
549          node_type => 6,
550        node_value => undef,        node_value => undef,
551        notation_name => undef,        notation_name => undef,
552        owner_document => $doc,        owner_document => $doc,
# Line 428  my $tests = { Line 555  my $tests = {
555        public_id => undef,        public_id => undef,
556        system_id => undef,        system_id => undef,
557      },      },
558        attr_get_bool => {
559          has_attributes => 0,
560          has_child_nodes => 0,
561        },
562    },    },
563    entity_reference => {    entity_reference => {
564      node => sub { return $doc->create_entity_reference ('e') },      node => sub { return $doc->create_entity_reference ('e') },
# Line 435  my $tests = { Line 566  my $tests = {
566        attributes => undef,        attributes => undef,
567        base_uri => undef,        base_uri => undef,
568        manakai_entity_base_uri => undef,        manakai_entity_base_uri => undef,
569          manakai_expanded_uri => undef,
570        first_child => undef,        first_child => undef,
571        last_child => undef,        last_child => undef,
572        local_name => undef,        local_name => undef,
# Line 442  my $tests = { Line 574  my $tests = {
574        namespace_uri => undef,        namespace_uri => undef,
575        next_sibling => undef,        next_sibling => undef,
576        node_name => 'e',        node_name => 'e',
577          node_type => 5,
578        node_value => undef,        node_value => undef,
579        owner_document => $doc,        owner_document => $doc,
580        parent_node => undef,        parent_node => undef,
# Line 451  my $tests = { Line 584  my $tests = {
584      attr_get_bool => {      attr_get_bool => {
585        manakai_expanded => 0,        manakai_expanded => 0,
586        manakai_external => 0,        manakai_external => 0,
587          has_attributes => 0,
588          has_child_nodes => 0,
589      },      },
590    },    },
591    notation => {    notation => {
# Line 459  my $tests = { Line 594  my $tests = {
594        attributes => undef,        attributes => undef,
595        base_uri => undef,        base_uri => undef,
596        manakai_declaration_base_uri => undef,        manakai_declaration_base_uri => undef,
597          manakai_expanded_uri => undef,
598        first_child => undef,        first_child => undef,
599        last_child => undef,        last_child => undef,
600        local_name => undef,        local_name => undef,
# Line 466  my $tests = { Line 602  my $tests = {
602        namespace_uri => undef,        namespace_uri => undef,
603        next_sibling => undef,        next_sibling => undef,
604        node_name => 'e',        node_name => 'e',
605          node_type => 12,
606        node_value => undef,        node_value => undef,
607        owner_document => $doc,        owner_document => $doc,
608        parent_node => undef,        parent_node => undef,
# Line 474  my $tests = { Line 611  my $tests = {
611        public_id => undef,        public_id => undef,
612        system_id => undef,        system_id => undef,
613      },      },
614        attr_get_bool => {
615          has_attributes => 0,
616          has_child_nodes => 0,
617        },
618    },    },
619    processing_instruction => {    processing_instruction => {
620      node => sub { return $doc->create_processing_instruction ('t', 'd') },      node => sub { return $doc->create_processing_instruction ('t', 'd') },
# Line 481  my $tests = { Line 622  my $tests = {
622        attributes => undef,        attributes => undef,
623        base_uri => undef,        base_uri => undef,
624        manakai_base_uri => undef,        manakai_base_uri => undef,
625          manakai_expanded_uri => undef,
626        first_child => undef,        first_child => undef,
627        last_child => undef,        last_child => undef,
628        local_name => undef,        local_name => undef,
# Line 488  my $tests = { Line 630  my $tests = {
630        namespace_uri => undef,        namespace_uri => undef,
631        next_sibling => undef,        next_sibling => undef,
632        node_name => 't',        node_name => 't',
633          node_type => 7,
634        node_value => 'd',        node_value => 'd',
635        owner_document => $doc,        owner_document => $doc,
636        parent_node => undef,        parent_node => undef,
637        prefix => undef,        prefix => undef,
638        previous_sibling => undef,        previous_sibling => undef,
639      },      },
640        attr_get_bool => {
641          has_attributes => 0,
642          has_child_nodes => 0,
643        },
644    },    },
645    text => {    text => {
646      node => sub { return $doc->create_text_node ('textdata') },      node => sub { return $doc->create_text_node ('textdata') },
647      attr_get => {      attr_get => {
648        attributes => undef,        attributes => undef,
649        base_uri => undef,        base_uri => undef,
650          manakai_expanded_uri => undef,
651        first_child => undef,        first_child => undef,
652        last_child => undef,        last_child => undef,
653        local_name => undef,        local_name => undef,
# Line 507  my $tests = { Line 655  my $tests = {
655        namespace_uri => undef,        namespace_uri => undef,
656        next_sibling => undef,        next_sibling => undef,
657        node_name => '#text',        node_name => '#text',
658          node_type => 3,
659        node_value => 'textdata',        node_value => 'textdata',
660        owner_document => $doc,        owner_document => $doc,
661        parent_node => undef,        parent_node => undef,
662        prefix => undef,        prefix => undef,
663        previous_sibling => undef,        previous_sibling => undef,
664      },      },
665        attr_get_bool => {
666          has_attributes => 0,
667          has_child_nodes => 0,
668        },
669    },    },
670    element_type_definition => {    element_type_definition => {
671      node => sub { return $doc->create_element_type_definition ('e') },      node => sub { return $doc->create_element_type_definition ('e') },
672      attr_get => {      attr_get => {
673        attributes => undef,        attributes => undef,
674        base_uri => undef,        base_uri => undef,
675          manakai_expanded_uri => undef,
676        first_child => undef,        first_child => undef,
677        last_child => undef,        last_child => undef,
678        local_name => undef,        local_name => undef,
# Line 526  my $tests = { Line 680  my $tests = {
680        namespace_uri => undef,        namespace_uri => undef,
681        next_sibling => undef,        next_sibling => undef,
682        node_name => 'e',        node_name => 'e',
683          node_type => 81001,
684        node_value => undef,        node_value => undef,
685        owner_document => $doc,        owner_document => $doc,
686        parent_node => undef,        parent_node => undef,
687        prefix => undef,        prefix => undef,
688        previous_sibling => undef,        previous_sibling => undef,
689      },      },
690        attr_get_bool => {
691          has_attributes => 0,
692          has_child_nodes => 0,
693        },
694    },    },
695    attribute_definition => {    attribute_definition => {
696      node => sub { return $doc->create_attribute_definition ('e') },      node => sub { return $doc->create_attribute_definition ('e') },
# Line 540  my $tests = { Line 699  my $tests = {
699        base_uri => undef,        base_uri => undef,
700        declared_type => 0,        declared_type => 0,
701        default_type => 0,        default_type => 0,
702          manakai_expanded_uri => undef,
703        first_child => undef,        first_child => undef,
704        last_child => undef,        last_child => undef,
705        local_name => undef,        local_name => undef,
# Line 547  my $tests = { Line 707  my $tests = {
707        namespace_uri => undef,        namespace_uri => undef,
708        next_sibling => undef,        next_sibling => undef,
709        node_name => 'e',        node_name => 'e',
710          node_type => 81002,
711        node_value => undef,        node_value => undef,
712        owner_document => $doc,        owner_document => $doc,
713        parent_node => undef,        parent_node => undef,
714        prefix => undef,        prefix => undef,
715        previous_sibling => undef,        previous_sibling => undef,
716      },      },
717        attr_get_bool => {
718          has_attributes => 0,
719          has_child_nodes => 0,
720        },
721    },    },
722  };  };
723    
# Line 1019  for my $i (0..1) { Line 1184  for my $i (0..1) {
1184             ]->[$i];             ]->[$i];
1185    
1186    my $doc2 = $doc->implementation->create_document;    my $doc2 = $doc->implementation->create_document;
1187      $doc2->strict_error_checking (0);
1188    
1189    my $attr = $doc2->create_attribute_ns (@$xb);    my $attr = $doc2->create_attribute_ns (@$xb);
1190    $attr->value (q<http://attr.test/>);    $attr->value (q<http://attr.test/>);
# Line 1221  for (qw/create_text_node create_cdata_se Line 1387  for (qw/create_text_node create_cdata_se
1387    ok $dt->base_uri, q<http://doc.test/>, "DT->base_uri [1]";    ok $dt->base_uri, q<http://doc.test/>, "DT->base_uri [1]";
1388  }  }
1389    
1390    ## |hasAttribute|
1391    {
1392      my $el = $doc->create_element ('e');
1393      ok $el->has_attributes ? 1 : 0, 0, "Element->has_attributes [0]";
1394    
1395      $el->set_attribute (a => 'b');
1396      ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [1]";
1397    
1398      $el->set_attribute (c => 'd');
1399      ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [2]";
1400    
1401      $el->remove_attribute ('c');
1402      ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [3]";
1403    
1404      $el->get_attribute_node ('a')->specified (0);
1405      ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [4]";
1406    
1407      $el->remove_attribute ('a');
1408      ok $el->has_attributes ? 1 : 0, 0, "Element->has_attributes [5]";
1409    }
1410    
1411    ## |hasChildNodes|
1412    {
1413      my $doc2 = $doc->implementation->create_document;
1414      
1415      ok $doc2->has_child_nodes ? 1 : 0, 0, "Document->has_child_nodes [0]";
1416    
1417      $doc2->append_child ($doc2->create_comment (''));
1418      ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [1]";
1419    
1420      $doc2->append_child ($doc2->create_comment (''));
1421      ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [2]";
1422    
1423      $doc2->remove_child ($doc2->first_child);
1424      ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [3]";
1425    
1426      $doc2->remove_child ($doc2->first_child);
1427      ok $doc2->has_child_nodes ? 1 : 0, 0, "Document->has_child_nodes [4]";
1428    }
1429    
1430    ## |compareDocumentPosition|
1431    {
1432      my $e1 = $doc->create_element ('e1');
1433      my $e2 = $doc->create_element ('e2');
1434      
1435      my $dp2 = $e1->compare_document_position ($e2);
1436      
1437      ok $dp2 & $e1->DOCUMENT_POSITION_DISCONNECTED ? 1 : 0, 1, "cdp [1]";
1438      ok $dp2 & $e1->DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ? 1 : 0, 1, "edp [2]";
1439      ok (($dp2 & $e1->DOCUMENT_POSITION_PRECEDING ||
1440           $dp2 & $e1->DOCUMENT_POSITION_FOLLOWING) ? 1 : 0, 1, "cdp [3]");
1441    
1442      my $dp1 = $e2->compare_document_position ($e1);
1443      
1444      ok $dp1 & $e1->DOCUMENT_POSITION_DISCONNECTED ? 1 : 0, 1, "cdp [4]";
1445      ok $dp1 & $e1->DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ? 1 : 0, 1, "cdp [5]";
1446      ok (($dp1 & $e1->DOCUMENT_POSITION_PRECEDING ||
1447           $dp1 & $e1->DOCUMENT_POSITION_FOLLOWING) ? 1 : 0, 1, "cdp [6]");
1448    }
1449    
1450    {
1451      my $e1 = $doc->create_element ('e1');
1452      my $e2 = $doc->create_element ('e2');
1453    
1454      my $pe = $doc->create_element ('pe');
1455      $pe->append_child ($e1);
1456      $pe->append_child ($e2);
1457    
1458      my $dp2 = $e1->compare_document_position ($e2);
1459    
1460      ok $dp2 & $e1->DOCUMENT_POSITION_FOLLOWING ? 1 : 0, 1, "cde [7]";
1461    
1462      my $dp1 = $e2->compare_document_position ($e1);
1463    
1464      ok $dp1 & $e1->DOCUMENT_POSITION_PRECEDING ? 1 : 0, 1, "cde [8]";
1465    }
1466    ## TODO: Apparently compare_document_position requires more tests.
1467    
1468    ## |lookupNamespaceURI|
1469    {
1470      for my $node (create_nodes ()) {
1471        ok $node->lookup_namespace_uri ('ns1'), undef, $node->node_name . " lnu [0]";
1472        ok $node->lookup_namespace_uri ('xml'), undef, $node->node_name . " lnu [1]";
1473        ok $node->lookup_namespace_uri ('xmlns'), undef, $node->node_name . " lnu [2]";
1474        ok $node->lookup_namespace_uri (''), undef, $node->node_name . " lnu [3]";
1475        ok $node->lookup_namespace_uri (undef), undef, $node->node_name . " lnu [4]";
1476      }
1477    
1478      my $el = $doc->create_element_ns ('about:', 'el');
1479      ok $el->lookup_namespace_uri ('ns1'), undef, 'Element->lnu [0]';
1480    
1481      $el->prefix ('ns1');
1482      ok $el->lookup_namespace_uri ('ns1'), 'about:', 'Element->lnu [1]';
1483    
1484      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns:ns1', 'DAV:');
1485      ok $el->lookup_namespace_uri ('ns1'), 'about:', 'Element->lnu [2]';
1486    
1487      $el->prefix (undef);
1488      ok $el->lookup_namespace_uri ('ns1'), 'DAV:', 'Element->lnu [3]';
1489    }
1490    
1491    ## |lookupPrefix|
1492    {
1493      for my $node (create_nodes ()) {
1494        ok $node->lookup_prefix ('http://test/'), undef, $node->node_name . "lp [0]";
1495        ok $node->lookup_prefix ('http://www.w3.org/XML/1998/namespace'), undef, $node->node_name . "lp [1]";
1496        ok $node->lookup_prefix ('http://www.w3.org/2000/xmlns/'), undef, $node->node_name . "lp [2]";
1497        ok $node->lookup_prefix ('http://www.w3.org/1999/xhtml'), undef, $node->node_name . "lp [3]";
1498        ok $node->lookup_prefix (''), undef, $node->node_name . "lp [4]";
1499        ok $node->lookup_prefix (undef), undef, $node->node_name . "lp [5]";
1500      }
1501    
1502      my $el = $doc->create_element_ns ('http://test/', 'e');
1503      ok $el->lookup_prefix ('ns'), undef, "Element->lp [0]";;
1504    
1505      my $el2 = $doc->create_element_ns ('http://test/', 'f');
1506      $el2->append_child ($el);
1507      $el2->prefix ('ns');
1508      ok $el->lookup_prefix ('http://test/'), 'ns', "Element->lp [1]";
1509    
1510      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns:a',
1511                             'http://test/');
1512      ok $el->lookup_prefix ('http://test/'), 'a', "Element->lp [2]";
1513    
1514      $el->prefix ('b');
1515      ok $el->lookup_prefix ('http://test/'), 'b', "Element->lp [3]";
1516    }
1517    
1518    ## |isDefaultNamespace|
1519    {
1520      for my $node (create_nodes ()) {
1521        next if $node->node_type == 1;
1522        ok $node->is_default_namespace ('about:') ? 1 : 0, 0, $node->node_name."idn[0]";
1523        ok $node->is_default_namespace ('http://www.w3.org/XML/1998/namespace') ? 1 : 0, 0, $node->node_name."idn[2]";
1524        ok $node->is_default_namespace ('http://www.w3.org/2000/xmlns/') ? 1 : 0, 0, $node->node_name."idn[3]";
1525        ok $node->is_default_namespace ('') ? 1 : 0, 0, $node->node_name."idn[4]";
1526        ok $node->is_default_namespace (undef) ? 1 : 0, 0, $node->node_name."idn[5]";
1527      }
1528      
1529      my $el = $doc->create_element_ns ('about:', 'el');
1530      ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [0]";
1531      
1532      $el->prefix ('ns1');
1533      ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [1]";
1534    
1535      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:');
1536      ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [2]";
1537      
1538      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'about:');
1539      ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [3]";
1540    
1541      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', '');
1542      ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [4]";
1543    }
1544    
1545    {
1546      my $el = $doc->create_element_ns ('about:', 'p:el');
1547      ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [5]";
1548      
1549      $el->prefix ('ns1');
1550      ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [6]";
1551    
1552      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:');
1553      ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [7]";
1554      
1555      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'about:');
1556      ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [8]";
1557    
1558      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', '');
1559      ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [9]";
1560    }
1561    
1562    {
1563      my $el = $doc->create_element ('e');
1564    
1565      ## NOTE: This might look like strange, but it is how it is defined!
1566      ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [10]";
1567      ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [11]";
1568    
1569      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:');
1570      ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [12]";
1571      ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [13]";
1572    
1573      $el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', '');
1574      ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [14]";
1575      ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [15]";
1576    }
1577    
1578    ## |manakaiParentElement|
1579    {
1580      my $el = $doc->create_element ('el');
1581      ok $el->manakai_parent_element, undef, "mpe [0]";
1582    
1583      my $el2 = $doc->create_element ('el2');
1584      $el->append_child ($el2);
1585      ok $el2->manakai_parent_element, $el, "mpe [1]";
1586      
1587      my $er1 = $doc->create_entity_reference ('er1');
1588      $er1->manakai_set_read_only (0, 1);
1589      $el->append_child ($er1);
1590      $er1->append_child ($el2);
1591      ok $el2->manakai_parent_element, $el, "mpe [1]";
1592    }
1593    
1594    {
1595      my $el = $doc->create_element ('el');
1596      my $t1 = $doc->create_text_node ('t1');
1597      my $t2 = $doc->create_text_node ('t2');
1598      $el->append_child ($t1);
1599      $el->append_child ($t2);
1600      $el->normalize;
1601      
1602      ok $el->text_content, 't1t2', 'normalize [0]';
1603      ok 0+@{$el->child_nodes}, 1, 'normalize [1]';
1604    }
1605    
1606    {
1607      my $el = $doc->create_element ('el');
1608      my $t1 = $doc->create_text_node ('t1');
1609      my $t2 = $doc->create_text_node ('t2');
1610      my $t3 = $doc->create_text_node ('t3');
1611      my $t4 = $doc->create_text_node ('t4');
1612      $el->append_child ($t1);
1613      $el->append_child ($t2);
1614      $el->append_child ($t3);
1615      $el->append_child ($t4);
1616      $el->normalize;
1617      
1618      ok $el->text_content, 't1t2t3t4', 'normalize [2]';
1619      ok 0+@{$el->child_nodes}, 1, 'normalize [3]';
1620    }
1621    
1622    {
1623      my $el = $doc->create_element ('el');
1624      my $t1 = $doc->create_text_node ('t1');
1625      my $t2 = $doc->create_text_node ('t2');
1626      my $c1 = $doc->create_cdata_section ('c1');
1627      my $t3 = $doc->create_text_node ('t3');
1628      my $t4 = $doc->create_text_node ('t4');
1629      $el->append_child ($t1);
1630      $el->append_child ($t2);
1631      $el->append_child ($c1);
1632      $el->append_child ($t3);
1633      $el->append_child ($t4);
1634      $el->normalize;
1635      
1636      ok $el->text_content, 't1t2c1t3t4', 'normalize [4]';
1637      ok 0+@{$el->child_nodes}, 3, 'normalize [5]';
1638      ok $el->first_child->text_content, 't1t2', 'normalize [6]';
1639      ok $el->last_child->text_content, 't3t4', 'normalize [7]';
1640    }
1641    
1642    {
1643      my $el = $doc->create_element ('el');
1644      my $t1 = $doc->create_text_node ('t1');
1645      my $t2 = $doc->create_text_node ('');
1646      $el->append_child ($t1);
1647      $el->append_child ($t2);
1648      $el->normalize;
1649      
1650      ok $el->text_content, 't1', 'normalize [8]';
1651      ok 0+@{$el->child_nodes}, 1, 'normalize [9]';
1652    }
1653    
1654    {
1655      my $el = $doc->create_element ('el');
1656      my $t1 = $doc->create_text_node ('');
1657      my $t2 = $doc->create_text_node ('t2');
1658      $el->append_child ($t1);
1659      $el->append_child ($t2);
1660      $el->normalize;
1661      
1662      ok $el->text_content, 't2', 'normalize [10]';
1663      ok 0+@{$el->child_nodes}, 1, 'normalize [11]';
1664    }
1665    
1666    {
1667      my $el = $doc->create_element ('el');
1668      my $t1 = $doc->create_text_node ('');
1669      $el->append_child ($t1);
1670      $el->normalize;
1671      
1672      ok $el->text_content, '', 'normalize [12]';
1673      ok 0+@{$el->child_nodes}, 0, 'normalize [13]';
1674    }
1675    
1676    {
1677      my $pe = $doc->create_element ('pe');
1678      my $el = $doc->create_element ('el');
1679      my $t1 = $doc->create_text_node ('t1');
1680      my $t2 = $doc->create_text_node ('t2');
1681      $el->append_child ($t1);
1682      $el->append_child ($t2);
1683      $pe->append_child ($el);
1684      $pe->normalize;
1685      
1686      ok $el->text_content, 't1t2', 'normalize [14]';
1687      ok 0+@{$el->child_nodes}, 1, 'normalize [15]';
1688    }
1689    
1690    {
1691      my $pe = $doc->create_element ('pe');
1692      my $el = $doc->create_attribute ('a');
1693      my $t1 = $doc->create_text_node ('t1');
1694      my $t2 = $doc->create_text_node ('t2');
1695      $el->append_child ($t1);
1696      $el->append_child ($t2);
1697      $pe->set_attribute_node ($el);
1698      $pe->normalize;
1699      
1700      ok $el->text_content, 't1t2', 'normalize [16]';
1701      ok 0+@{$el->child_nodes}, 1, 'normalize [17]';
1702    }
1703    
1704    {
1705      my $pe = $doc->create_element_type_definition ('pe');
1706      my $el = $doc->create_attribute_definition ('a');
1707      my $t1 = $doc->create_text_node ('t1');
1708      my $t2 = $doc->create_text_node ('t2');
1709      $el->append_child ($t1);
1710      $el->append_child ($t2);
1711      $pe->set_attribute_definition_node ($el);
1712      $pe->normalize;
1713      
1714      ok $el->text_content, 't1t2', 'normalize [16]';
1715      ok 0+@{$el->child_nodes}, 1, 'normalize [17]';
1716    }
1717    
1718    {
1719      my $dt = $doc->create_document_type_definition ('dt');
1720      my $pe = $doc->create_element_type_definition ('pe');
1721      my $el = $doc->create_attribute_definition ('a');
1722      my $t1 = $doc->create_text_node ('t1');
1723      my $t2 = $doc->create_text_node ('t2');
1724      $el->append_child ($t1);
1725      $el->append_child ($t2);
1726      $pe->set_attribute_definition_node ($el);
1727      $dt->set_element_type_definition_node ($pe);
1728      $dt->normalize;
1729      
1730      ok $el->text_content, 't1t2', 'normalize [18]';
1731      ok 0+@{$el->child_nodes}, 1, 'normalize [19]';
1732    }
1733    
1734    {
1735      my $pe = $doc->create_document_type_definition ('pe');
1736      my $el = $doc->create_general_entity ('a');
1737      my $t1 = $doc->create_text_node ('t1');
1738      my $t2 = $doc->create_text_node ('t2');
1739      $el->append_child ($t1);
1740      $el->append_child ($t2);
1741      $pe->set_general_entity_node ($el);
1742      $pe->normalize;
1743      
1744      ok $el->text_content, 't1t2', 'normalize [20]';
1745      ok 0+@{$el->child_nodes}, 1, 'normalize [21]';
1746    }
1747    
1748  ## TODO: parent_node tests, as with append_child tests  ## TODO: parent_node tests, as with append_child tests
1749    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24  
Google Analytics is used in this page; Cookies are used. 忍者AdMax is used in this page; Cookies are used. Privacy policy.