1 |
wakaba |
1.1 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
require Message::Markup::SuikaWikiConfig20::Node; |
4 |
|
|
|
5 |
|
|
my $cfg = Message::Markup::SuikaWikiConfig20::Node->new (type => '#document'); |
6 |
|
|
|
7 |
|
|
$cfg->append_new_node (type => '#element', local_name => 'foo') |
8 |
|
|
->inner_text (new_value => 'aiueo'); |
9 |
|
|
$cfg->append_new_node (type => '#comment', value => 'comment |
10 |
|
|
(multiple lines)'); |
11 |
|
|
$cfg->append_new_node (type => '#comment', value => 'comment |
12 |
|
|
(multiple lines)'); |
13 |
|
|
$cfg->append_new_node (type => '#element', local_name => 'foo', value => 'val'); |
14 |
|
|
$cfg->append_new_node (type => '#element', local_name => 'foo', value => 'value |
15 |
|
|
with multiple |
16 |
|
|
lines'); |
17 |
|
|
$cfg->append_new_node (type => '#element', local_name => 'name with |
18 |
|
|
multiple lines', value => 'val'); |
19 |
|
|
$cfg->append_new_node (type => '#element', local_name => 'foo', value => 'value |
20 |
|
|
with multiple |
21 |
|
|
@ lines |
22 |
|
|
\ escaped |
23 |
|
|
'); |
24 |
|
|
|
25 |
|
|
my $t = $cfg->append_new_node (type => '#element', local_name => 'name', value => 'val'); |
26 |
|
|
$t->append_new_node (type => '#element', local_name => 'foo', value => 'bar'); |
27 |
|
|
$t->append_new_node (type => '#element', local_name => 'foo', value => '0'); |
28 |
|
|
$t->append_new_node (type => '#element', local_name => '@', value => '@ foo'); |
29 |
|
|
$t->append_new_node (type => '#element', local_name => 'foo', value => 'something multi |
30 |
|
|
|
31 |
|
|
line'); |
32 |
|
|
$t->append_new_node (type => '#comment', value => 'comment'); |
33 |
|
|
my $tt = $t->append_new_node (type => '#element', local_name => 'foo', value => 'something\ |
34 |
|
|
multi |
35 |
|
|
|
36 |
|
|
line'); |
37 |
|
|
$tt->append_new_node (type => '#element', local_name => 'foo', value => 'bar'); |
38 |
|
|
$tt->append_new_node (type => '#element', local_name => 'foo', value => '0'); |
39 |
|
|
$tt->append_new_node (type => '#element', local_name => '@', value => '@ foo'); |
40 |
|
|
$tt->append_new_node (type => '#element', local_name => 'foo', value => 'something\ |
41 |
|
|
multi |
42 |
|
|
|
43 |
|
|
line'); |
44 |
|
|
$cfg->append_new_node (type => '#comment', value => '##COMMENT##'); |
45 |
|
|
$tt->append_new_node (type => '#element', local_name => 'foolist', value => [qw/foo bar #baz bar/]); |
46 |
|
|
|
47 |
|
|
require Test::Simple; |
48 |
|
|
my @s = split /\n/, $cfg->stringify; |
49 |
|
|
my @t = split /\n/, q(foo: aiueo |
50 |
|
|
#comment |
51 |
|
|
#(multiple lines) |
52 |
|
|
|
53 |
|
|
#comment |
54 |
|
|
#(multiple lines) |
55 |
|
|
foo: val |
56 |
|
|
foo: |
57 |
|
|
value |
58 |
|
|
with multiple |
59 |
|
|
\ lines |
60 |
|
|
name with |
61 |
|
|
multiple lines: val |
62 |
|
|
foo: |
63 |
|
|
value |
64 |
|
|
with multiple |
65 |
|
|
\@ lines |
66 |
|
|
\\\\ escaped |
67 |
|
|
\ |
68 |
|
|
name: |
69 |
|
|
@@: val |
70 |
|
|
@foo: bar |
71 |
|
|
@foo: 0 |
72 |
|
|
@\@: \@ foo |
73 |
|
|
@foo: |
74 |
|
|
something multi |
75 |
|
|
\ |
76 |
|
|
\ line |
77 |
|
|
@foo: |
78 |
|
|
@@@: |
79 |
|
|
something\ |
80 |
|
|
\ multi |
81 |
|
|
\ |
82 |
|
|
\ line |
83 |
|
|
@@foo: bar |
84 |
|
|
@@foo: 0 |
85 |
|
|
@@\@: \@ foo |
86 |
|
|
@@foo: |
87 |
|
|
something\ |
88 |
|
|
\ multi |
89 |
|
|
\ |
90 |
|
|
\ line |
91 |
|
|
@@foolist[list]: |
92 |
|
|
foo |
93 |
|
|
bar |
94 |
|
|
\#baz |
95 |
|
|
bar |
96 |
|
|
###COMMENT## |
97 |
|
|
); |
98 |
|
|
|
99 |
|
|
Test::Simple->import (tests => scalar @t); |
100 |
|
|
for (0..($#t > $#s ? $#t : $#s)) { |
101 |
|
|
ok ($s[$_] eq $t[$_], "Line $_ : '$s[$_]' '$t[$_]'"); |
102 |
|
|
} |