1 |
#!/usr/bin/perl |
2 |
use strict; |
3 |
use Test; |
4 |
BEGIN { plan tests => 43 } |
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 |
for my $v ( |
13 |
[a => undef], |
14 |
[abc => undef], |
15 |
['a:b' => undef], |
16 |
[1 => 'INVALID_CHARACTER_ERR'], |
17 |
[1234 => 'INVALID_CHARACTER_ERR'], |
18 |
["\x{3001}\x{3002}" => 'INVALID_CHARACTER_ERR'], ## XML 1.1 Name |
19 |
[':aa' => undef], |
20 |
[':1' => undef], |
21 |
['a:' => undef], |
22 |
["a:\x{3005}b" => undef], ## XML 1.0 Name, XML 1.1 QName |
23 |
) { |
24 |
$doc->strict_error_checking (1); |
25 |
if (not defined $v->[1]) { |
26 |
try { |
27 |
my $dt = $doc->create_notation ($v->[0]); |
28 |
ok $dt->node_name, $v->[0], 'create_notation '.$v->[0]; |
29 |
} catch Message::IF::DOMException with { |
30 |
my $e = shift; |
31 |
ok $e->type, undef, 'create_notation '.$v->[0]; |
32 |
}; |
33 |
} else { |
34 |
try { |
35 |
$doc->create_notation ($v->[0]); |
36 |
ok 0, 1, 'create_notation '.$v->[0]; |
37 |
} catch Message::IF::DOMException with { |
38 |
my $e = shift; |
39 |
ok $e->type, $v->[1], 'create_notation '.$v->[0]; |
40 |
}; |
41 |
} |
42 |
$doc->strict_error_checking (0); |
43 |
my $dt = $doc->create_notation ($v->[0]); |
44 |
ok $dt->node_name, $v->[0], 'create_notation s '.$v->[0]; |
45 |
} |
46 |
$doc->strict_error_checking (1); |
47 |
|
48 |
my $ent = $doc->create_notation ('entity'); |
49 |
|
50 |
for my $prop (qw/public_id system_id/) { |
51 |
ok $ent->can ($prop) ? 1 : 0, 1, 'can ' . $prop; |
52 |
|
53 |
for ('-//...//EN', 'http://absuri.test/', 'reluri', |
54 |
qq('illegal"), qq'\x{4E00}', 0, '') { |
55 |
$ent->$prop ($_); |
56 |
ok $ent->$prop, $_, $prop . $_; |
57 |
} |
58 |
|
59 |
$ent->$prop (undef); |
60 |
ok $ent->$prop, undef, $prop . ' undef'; |
61 |
} |
62 |
|
63 |
## |manakaiDeclarationBaseURI| |
64 |
{ |
65 |
my $doc2 = $doc->implementation->create_document; |
66 |
my $ent = $doc2->create_notation ('notation'); |
67 |
|
68 |
ok $ent->can ('manakai_declaration_base_uri') ? 1 : 0, 1, |
69 |
'can manakai_declaration_base_uri'; |
70 |
|
71 |
$doc2->document_uri (q<http://www.example/>); |
72 |
ok $ent->manakai_declaration_base_uri, q<http://www.example/>, |
73 |
'manakai_declaration_base_uri document_uri'; |
74 |
|
75 |
$ent->manakai_declaration_base_uri (q<ftp://www.example/>); |
76 |
ok $ent->manakai_declaration_base_uri, q<ftp://www.example/>, |
77 |
'manakai_declaration_base_uri explicit'; |
78 |
ok $ent->base_uri, q<http://www.example/>, |
79 |
'manakai_declaration_base_uri (base_uri)'; |
80 |
|
81 |
$ent->manakai_declaration_base_uri (undef); |
82 |
ok $ent->manakai_declaration_base_uri, q<http://www.example/>, |
83 |
'manakai_declaration_base_uri reset'; |
84 |
} |
85 |
|
86 |
=head1 LICENSE |
87 |
|
88 |
Copyright 2007 Wakaba <w@suika.fam.cx> |
89 |
|
90 |
This program is free software; you can redistribute it and/or |
91 |
modify it under the same terms as Perl itself. |
92 |
|
93 |
=cut |
94 |
|
95 |
## $Date: 2007/06/17 13:37:42 $ |