1 |
wakaba |
1.1 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use Test; |
4 |
wakaba |
1.2 |
BEGIN { plan tests => 33 } |
5 |
wakaba |
1.1 |
|
6 |
|
|
require Message::DOM::DOMImplementation; |
7 |
|
|
use Message::Util::Error; |
8 |
|
|
|
9 |
wakaba |
1.2 |
my $dom = Message::DOM::DOMImplementation->new; |
10 |
wakaba |
1.1 |
my $doc = $dom->create_document; |
11 |
|
|
|
12 |
|
|
my $el = $doc->create_processing_instruction ('pi'); |
13 |
|
|
|
14 |
|
|
for my $prop (qw/manakai_base_uri/) { |
15 |
|
|
ok $el->can ($prop) ? 1 : 0, 1, 'can ' . $prop; |
16 |
|
|
|
17 |
|
|
for ('http://absuri.test/', 'reluri', 0, '') { |
18 |
|
|
$el->$prop ($_); |
19 |
|
|
ok $el->$prop, $_, $prop . $_; |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
$el->$prop (undef); |
23 |
|
|
ok $el->$prop, undef, $prop . ' undef'; |
24 |
|
|
} |
25 |
|
|
|
26 |
wakaba |
1.2 |
## |nodeValue|, |textContent|, |data| |
27 |
|
|
{ |
28 |
|
|
my $node = $doc->create_processing_instruction ('pi', 'initial'); |
29 |
|
|
ok $node->node_value, 'initial', 'node_value [1]'; |
30 |
|
|
ok $node->text_content, 'initial', 'text_content [1]'; |
31 |
|
|
ok $node->data, 'initial', 'data [1]'; |
32 |
|
|
|
33 |
|
|
$node->node_value ('value1'); |
34 |
|
|
ok $node->node_value, 'value1', 'node_value [2]'; |
35 |
|
|
ok $node->text_content, 'value1', 'text_content [2]'; |
36 |
|
|
ok $node->data, 'value1', 'data [2]'; |
37 |
|
|
|
38 |
|
|
$node->node_value (''); |
39 |
|
|
ok $node->node_value, '', 'node_value [3]'; |
40 |
|
|
ok $node->text_content, '', 'text_content [3]'; |
41 |
|
|
ok $node->data, '', 'data [3]'; |
42 |
|
|
|
43 |
|
|
$node->text_content ('value3'); |
44 |
|
|
ok $node->node_value, 'value3', 'node_value [4]'; |
45 |
|
|
ok $node->text_content, 'value3', 'text_content [4]'; |
46 |
|
|
ok $node->data, 'value3', 'data [4]'; |
47 |
|
|
|
48 |
|
|
$node->text_content (''); |
49 |
|
|
ok $node->node_value, '', 'node_value [5]'; |
50 |
|
|
ok $node->text_content, '', 'text_content [5]'; |
51 |
|
|
ok $node->data, '', 'data [5]'; |
52 |
|
|
|
53 |
|
|
$node->text_content ('value4'); |
54 |
|
|
$node->text_content (undef); |
55 |
|
|
ok $node->node_value, '', 'node_value [6]'; |
56 |
|
|
ok $node->text_content, '', 'text_content [6]'; |
57 |
|
|
ok $node->data, '', 'data [6]'; |
58 |
|
|
|
59 |
|
|
$node->data ('value5'); |
60 |
|
|
ok $node->node_value, 'value5', 'node_value [7]'; |
61 |
|
|
ok $node->text_content, 'value5', 'text_content [7]'; |
62 |
|
|
ok $node->data, 'value5', 'data [7]'; |
63 |
|
|
|
64 |
|
|
$node->data (''); |
65 |
|
|
ok $node->node_value, '', 'node_value [8]'; |
66 |
|
|
ok $node->text_content, '', 'text_content [8]'; |
67 |
|
|
ok $node->data, '', 'data [8]'; |
68 |
|
|
|
69 |
|
|
$node->manakai_set_read_only (1); |
70 |
|
|
try { |
71 |
|
|
$node->node_value ('value6'); |
72 |
|
|
ok 0, 1, 'node_value [9]'; |
73 |
|
|
} catch Message::IF::DOMException with { |
74 |
|
|
ok $_[0]->type, 'NO_MODIFICATION_ALLOWED_ERR', 'node_value [9]'; |
75 |
|
|
}; |
76 |
|
|
try { |
77 |
|
|
$node->text_content ('value7'); |
78 |
|
|
ok 0, 1, 'text_content [9]'; |
79 |
|
|
} catch Message::IF::DOMException with { |
80 |
|
|
ok $_[0]->type, 'NO_MODIFICATION_ALLOWED_ERR', 'text_content [9]'; |
81 |
|
|
}; |
82 |
|
|
try { |
83 |
|
|
$node->data ('value8'); |
84 |
|
|
ok 0, 1, 'data [9]'; |
85 |
|
|
} catch Message::IF::DOMException with { |
86 |
|
|
ok $_[0]->type, 'NO_MODIFICATION_ALLOWED_ERR', 'data [9]'; |
87 |
|
|
}; |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
|
91 |
wakaba |
1.1 |
=head1 LICENSE |
92 |
|
|
|
93 |
|
|
Copyright 2007 Wakaba <w@suika.fam.cx> |
94 |
|
|
|
95 |
|
|
This program is free software; you can redistribute it and/or |
96 |
|
|
modify it under the same terms as Perl itself. |
97 |
|
|
|
98 |
|
|
=cut |
99 |
|
|
|
100 |
wakaba |
1.2 |
## $Date: 2007/06/17 13:37:42 $ |