1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
2 |
use strict; |
use strict; |
3 |
use Test; |
use Test; |
4 |
BEGIN { plan tests => 55 } |
BEGIN { plan tests => 128 } |
5 |
|
|
6 |
require Message::DOM::DOMImplementation; |
require Message::DOM::DOMImplementation; |
7 |
use Message::Util::Error; |
use Message::Util::Error; |
247 |
ok $doc2->manakai_compat_mode, 'no quirks', 'manakai_compat_mode [11]'; |
ok $doc2->manakai_compat_mode, 'no quirks', 'manakai_compat_mode [11]'; |
248 |
} |
} |
249 |
|
|
250 |
|
{ |
251 |
|
ok $doc->can ('implementation') ? 1 : 0, 1, 'Document->implementation can'; |
252 |
|
my $impl = $doc->implementation; |
253 |
|
ok UNIVERSAL::isa ($impl, 'Message::DOM::DOMImplementation') ? 1 : 0, |
254 |
|
1, 'Document->implementation class'; |
255 |
|
my $impl2 = $doc->implementation; |
256 |
|
ok $impl eq $impl2 ? 1 : 0, 1, 'Document->implementation eq D->i'; |
257 |
|
ok $impl ne $impl2 ? 1 : 0, 0, 'Document->implementation ne D->i'; |
258 |
|
ok $impl == $impl2 ? 1 : 0, 1, 'Document->implementation == D->i'; |
259 |
|
ok $impl != $impl2 ? 1 : 0, 0, 'Document->implementation != D->i'; |
260 |
|
} |
261 |
|
|
262 |
|
{ |
263 |
|
my $doc2 = $doc->implementation->create_document; |
264 |
|
ok $doc2->doctype, undef, 'Document->implementation [0]'; |
265 |
|
|
266 |
|
my $doctype = $doc2->implementation->create_document_type ('dt'); |
267 |
|
my $el = $doc2->create_element_ns (undef, 'e'); |
268 |
|
$doc2->append_child ($doctype); |
269 |
|
$doc2->append_child ($el); |
270 |
|
|
271 |
|
ok $doc2->doctype, $doctype, 'Document->implementation [1]'; |
272 |
|
} |
273 |
|
|
274 |
|
{ |
275 |
|
my $doc2 = $doc->implementation->create_document; |
276 |
|
my $doctype = $doc2->implementation->create_document_type ('dt'); |
277 |
|
my $el = $doc2->create_element_ns (undef, 'e'); |
278 |
|
my $comment = $doc->create_comment (''); |
279 |
|
$doc2->append_child ($comment); |
280 |
|
$doc2->append_child ($doctype); |
281 |
|
$doc2->append_child ($el); |
282 |
|
|
283 |
|
ok $doc2->doctype, $doctype, 'Document->implementation [2]'; |
284 |
|
} |
285 |
|
|
286 |
|
{ |
287 |
|
my $doc2 = $doc->implementation->create_document; |
288 |
|
ok $doc2->can ('document_element') ? 1 : 0, 1, 'Document->document_el can'; |
289 |
|
ok $doc2->document_element, undef, 'Document->document_element [0]'; |
290 |
|
|
291 |
|
my $el = $doc2->create_element_ns (undef, 'e'); |
292 |
|
$doc2->append_child ($el); |
293 |
|
|
294 |
|
ok $doc2->document_element, $el, 'Document->document_element [1]'; |
295 |
|
} |
296 |
|
|
297 |
|
{ |
298 |
|
my $doc2 = $doc->implementation->create_document; |
299 |
|
my $doctype = $doc2->implementation->create_document_type ('dt'); |
300 |
|
$doc2->append_child ($doctype); |
301 |
|
my $el = $doc2->create_element_ns (undef, 'e'); |
302 |
|
$doc2->append_child ($el); |
303 |
|
|
304 |
|
ok $doc2->document_element, $el, 'Document->document_element [1]'; |
305 |
|
} |
306 |
|
|
307 |
|
{ |
308 |
|
ok $doc->can ('dom_config') ? 1 : 0, 1, 'Document->dom_config can'; |
309 |
|
my $cfg = $doc->dom_config; |
310 |
|
ok UNIVERSAL::isa ($cfg, 'Message::IF::DOMConfiguration') ? 1 : 0, |
311 |
|
1, 'Document->dom_config interface'; |
312 |
|
} |
313 |
|
|
314 |
|
{ |
315 |
|
my $impl = $doc->implementation; |
316 |
|
my $doc1 = $impl->create_document; |
317 |
|
my $doc2 = $impl->create_document; |
318 |
|
|
319 |
|
ok $doc2->can ('adopt_node') ? 1 : 0, 1, 'Document->adopt_node can'; |
320 |
|
|
321 |
|
my $el1 = $doc1->create_element_ns (undef, 'e'); |
322 |
|
my $el2 = $doc2->adopt_node ($el1); |
323 |
|
|
324 |
|
ok $el1 eq $el2 ? 1 : 0, 1, 'Document->adopt_node return == source'; |
325 |
|
ok $el2->owner_document, $doc2, 'Document->adopt_node owner_document'; |
326 |
|
|
327 |
|
my $node = $doc1->create_element ('e'); |
328 |
|
my $udh_called = 0; |
329 |
|
$node->set_user_data (key => {}, sub { |
330 |
|
my ($op, $key, $data, $src, $dest) = @_; |
331 |
|
$udh_called = 1; |
332 |
|
|
333 |
|
ok $op, 5, 'adopt_node user data handler operation'; |
334 |
|
ok $key, 'key', 'adopt_node user data handler key'; |
335 |
|
ok ref $data, 'HASH', 'adopt_node user data handler data'; |
336 |
|
ok $src, $node, 'adopt_node user data handler src'; |
337 |
|
ok $dest, undef, 'adopt_node user data handler dest'; |
338 |
|
}); |
339 |
|
|
340 |
|
$doc2->adopt_node ($node); |
341 |
|
|
342 |
|
ok $udh_called, 1, 'Document->adopt_node udh called'; |
343 |
|
|
344 |
|
$node->set_user_data (key => undef, undef); |
345 |
|
|
346 |
|
my $el3 = $doc1->create_element_ns (undef, 'e'); |
347 |
|
my $el4 = $doc1->adopt_node ($el3); |
348 |
|
|
349 |
|
ok $el4, $el3, 'Document->adopt_node samedoc return'; |
350 |
|
ok $el4->owner_document, $doc1, 'Document->adopt_node samedoc od'; |
351 |
|
|
352 |
|
my $parent = $doc1->create_element ('pa'); |
353 |
|
my $child = $doc1->create_element ('ch'); |
354 |
|
$parent->append_child ($child); |
355 |
|
|
356 |
|
my $child2 = $doc2->adopt_node ($child); |
357 |
|
|
358 |
|
ok $child2, $child, 'Document->adopt_node return [2]'; |
359 |
|
ok $child2->owner_document, $doc2, 'Document->adopt_node->od [2]'; |
360 |
|
ok $child2->parent_node, undef, 'Document->adopt_node->parent_node [2]'; |
361 |
|
ok 0+@{$parent->child_nodes}, 0, 'Document->adopt_node parent->cn @{} 0+ [2]'; |
362 |
|
|
363 |
|
my $attr = $doc1->create_attribute ('e'); |
364 |
|
$parent->set_attribute_node ($attr); |
365 |
|
|
366 |
|
my $attr2 = $doc2->adopt_node ($attr); |
367 |
|
ok $attr2, $attr, 'Document->adopt_node return [3]'; |
368 |
|
ok $attr2->owner_document, $doc2, 'Document->adopt_node->od [3]'; |
369 |
|
ok $attr2->owner_element, undef, 'Document->adopt_node->oe [3]'; |
370 |
|
ok 0+@{$parent->attributes}, 0, 'Document->adopt_node parent->a @{} 0+ [3]'; |
371 |
|
} |
372 |
|
|
373 |
## TODO: manakai_entity_base_uri |
## TODO: manakai_entity_base_uri |
374 |
|
|
375 |
=head1 LICENSE |
=head1 LICENSE |