1 |
wakaba |
1.1 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use Test; |
4 |
wakaba |
1.2 |
BEGIN { plan tests => 79 } |
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 |
|
|
my $ent = $doc->create_attribute_definition ('ad'); |
13 |
|
|
|
14 |
|
|
## Constants |
15 |
|
|
my $constants = [ |
16 |
|
|
[NO_TYPE_ATTR => 0], |
17 |
|
|
[CDATA_ATTR => 1], |
18 |
|
|
[ID_ATTR => 2], |
19 |
|
|
[IDREF_ATTR => 3], |
20 |
|
|
[IDREFS_ATTR => 4], |
21 |
|
|
[ENTITY_ATTR => 5], |
22 |
|
|
[ENTITIES_ATTR => 6], |
23 |
|
|
[NMTOKEN_ATTR => 7], |
24 |
|
|
[NMTOKENS_ATTR => 8], |
25 |
|
|
[NOTATION_ATTR => 9], |
26 |
|
|
[ENUMERATION_ATTR => 10], |
27 |
|
|
[UNKNOWN_ATTR => 11], |
28 |
|
|
[UNKNOWN_DEFAULT => 0], |
29 |
|
|
[FIXED_DEFAULT => 1], |
30 |
|
|
[REQUIRED_DEFAULT => 2], |
31 |
|
|
[IMPLIED_DEFAULT => 3], |
32 |
|
|
[EXPLICIT_DEFAULT => 4], |
33 |
|
|
]; |
34 |
|
|
for (@$constants) { |
35 |
|
|
my $const_name = $_->[0]; |
36 |
|
|
ok $ent->can ($const_name) ? 1 : 0, 1, "can ($const_name)"; |
37 |
|
|
ok $ent->$const_name, $_->[1], $const_name; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
for my $prop (qw/declared_type default_type/) { |
41 |
|
|
ok $ent->can ($prop) ? 1 : 0, 1, 'can ' . $prop; |
42 |
|
|
local $^W = 0; |
43 |
|
|
|
44 |
|
|
for (-3..10, 'abc', '') { |
45 |
|
|
$ent->$prop ($_); |
46 |
|
|
ok $ent->$prop, 0+$_, $prop . $_; |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
$ent->$prop (undef); |
50 |
|
|
ok $ent->$prop, 0, $prop . ' undef'; |
51 |
|
|
} |
52 |
|
|
|
53 |
wakaba |
1.2 |
## allowedToken |
54 |
|
|
{ |
55 |
|
|
my $at = $doc->create_attribute_definition ('ay'); |
56 |
|
|
|
57 |
|
|
ok $at->can ('allowed_tokens') ? 1 : 0, 1, 'can allowedTokens'; |
58 |
|
|
|
59 |
|
|
my $list = $at->allowed_tokens; |
60 |
|
|
ok UNIVERSAL::isa ($list, 'Message::IF::DOMStringList') ? 1 : 0, 1, |
61 |
|
|
'allowedTokens interface'; |
62 |
|
|
ok 0+@$list, 0, 'allowedTokens @{} 0+'; |
63 |
|
|
|
64 |
|
|
push @$list, 'NMTOKEN'; |
65 |
|
|
ok $list->[0], 'NMTOKEN', 'allowedTokens->[0]'; |
66 |
|
|
undef $list; |
67 |
|
|
|
68 |
|
|
my $list2 = $at->allowed_tokens; |
69 |
|
|
ok $list2->[0], 'NMTOKEN', 'allowedTokens->[0] 2'; |
70 |
|
|
|
71 |
|
|
my $list3 = $at->allowed_tokens; |
72 |
|
|
my $at2 = $doc->create_attribute_definition ('at2'); |
73 |
|
|
my $list4 = $at2->allowed_tokens; |
74 |
|
|
|
75 |
|
|
ok $list2 eq $list3 ? 1 : 0, 1, 'allowedTokens eq allowedTokens'; |
76 |
|
|
ok $list2 ne $list3 ? 1 : 0, 0, 'allowedTokens ne allowedTokens'; |
77 |
|
|
ok $list2 eq $list4 ? 1 : 0, 0, 'allowedTokens eq allowedTokens2'; |
78 |
|
|
ok $list2 ne $list4 ? 1 : 0, 1, 'allowedTokens ne allowedTokens2'; |
79 |
|
|
} |
80 |
|
|
|
81 |
wakaba |
1.1 |
=head1 LICENSE |
82 |
|
|
|
83 |
|
|
Copyright 2007 Wakaba <w@suika.fam.cx> |
84 |
|
|
|
85 |
|
|
This program is free software; you can redistribute it and/or |
86 |
|
|
modify it under the same terms as Perl itself. |
87 |
|
|
|
88 |
|
|
=cut |
89 |
|
|
|
90 |
wakaba |
1.2 |
## $Date: 2007/06/17 13:37:42 $ |