1
2
3use strict;
4use warnings;
5use Test;
6BEGIN { plan tests => 11 };
7
8my $d;
9#use Pod::Simple::Debug (\$d, 0);
10
11ok 1;
12
13use Pod::Simple::XMLOutStream;
14use Pod::Simple::DumpAsXML;
15
16
17$Pod::Simple::XMLOutStream::ATTR_PAD   = ' ';
18$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output
19
20
21print "# A simple sanity test...\n";
22ok( Pod::Simple::XMLOutStream->_out("=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"),
23 '<Document><Para><F><C>foo</C> <I>bar</I></F> <B>stuff <X>thing</X>baz</B></Para></Document>'
24);
25
26print "# With lots of nesting, and Z's...\n";
27ok( Pod::Simple::XMLOutStream->_out("=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"),
28 '<Document><Para><F><C>foo</C> <I>bar</I></F> <B>stuff <X>thing</X>baz</B></Para></Document>'
29);
30
31#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
33sub mergy {$_[0]->merge_text(1)}
34sub nixy  {$_[0]->nix_X_codes(1)}
35sub nixy_mergy {$_[0]->merge_text(1); $_[0]->nix_X_codes(1);}
36
37#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38
39print "# With no F/X\n";
40
41ok( Pod::Simple::DumpAsXML->_out( "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"),
42  join "\n",
43
44  '<Document>',
45  '  <Para>',
46  '    <F>',
47  '      <C>',
48  '        foo',
49  '      </C>',
50  '      ',
51  '      <I>',
52  '        bar',
53  '      </I>',
54  '    </F>',
55  '    ',
56  '    <B>',
57  '      stuff ',
58  '      <X>',
59  '        thing',
60  '      </X>',
61  '      baz',
62  '    </B>',
63  '  </Para>',
64  '</Document>',
65  '',
66);
67
68#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69
70print "#  with just X-nixing...\n";
71
72ok( Pod::Simple::DumpAsXML->_out( \&nixy, "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"),
73  join "\n",
74
75  '<Document>',
76  '  <Para>',
77  '    <F>',
78  '      <C>',
79  '        foo',
80  '      </C>',
81  '      ',
82  '      <I>',
83  '        bar',
84  '      </I>',
85  '    </F>',
86  '    ',
87  '    <B>',
88  '      stuff baz',
89  '    </B>',
90  '  </Para>',
91  '</Document>',
92  '',
93);
94
95#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96
97print "# With merging...\n";
98
99ok( Pod::Simple::DumpAsXML->_out( \&mergy, "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"),
100  join "\n",
101
102  '<Document>',
103  '  <Para>',
104  '    <F>',
105  '      <C>',
106  '        foo',
107  '      </C>',
108  '      ',
109  '      <I>',
110  '        bar',
111  '      </I>',
112  '    </F>',
113  '    ',
114  '    <B>',
115  '      stuff ',
116  '      <X>',
117  '        thing',
118  '      </X>',
119  '      baz',
120  '    </B>',
121  '  </Para>',
122  '</Document>',
123  '',
124);
125
126#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127
128print "# With nixing and merging...\n";
129#$d = 10;
130ok( Pod::Simple::DumpAsXML->_out( \&nixy_mergy, "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"),
131  join "\n",
132
133  '<Document>',
134  '  <Para>',
135  '    <F>',
136  '      <C>',
137  '        foo',
138  '      </C>',
139  '      ',
140  '      <I>',
141  '        bar',
142  '      </I>',
143  '    </F>',
144  '    ',
145  '    <B>',
146  '      stuff baz',
147  '    </B>',
148  '  </Para>',
149  '</Document>',
150  '',
151);
152
153#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154
155# Now the scary bits... with L's!
156print "# A wee L<...> sanity test...\n";
157ok( Pod::Simple::XMLOutStream->_out(qq{=pod\n\nL<E<78>et::Ping/Ping-E<112>ong>\n}),
158 '<Document><Para><L content-implicit="yes" raw="E&#60;78&#62;et::Ping/Ping-E&#60;112&#62;ong" section="Ping-pong" to="Net::Ping" type="pod">&#34;Ping-pong&#34; in Net::Ping</L></Para></Document>'
159);
160print "# Now a wee L<...> with mergy...\n";
161
162$d = 10;
163
164ok( Pod::Simple::DumpAsXML->_out(\&mergy, qq{=pod\n\nL<E<78>et::Ping/Ping-E<112>ong>\n}),
165 join "\n",
166
167 '<Document>',
168 '  <Para>',
169 '    <L content-implicit="yes" raw="E&#60;78&#62;et::Ping/Ping-E&#60;112&#62;ong" section="Ping-pong" to="Net::Ping" type="pod">',
170 '      &#34;Ping-pong&#34; in Net::Ping',
171 '    </L>',
172 '  </Para>',
173 '</Document>',
174 ''
175);
176
177
178print "# Now a complex tree with L's, with nixy+mergy...\n";
179
180ok( Pod::Simple::DumpAsXML->_out( \&nixy_mergy, "=pod\n\nZ<>F<C<Z<>fE<111>L<E<78>et::Ping/Ping-E<112>ong>o> I<bar>> B<stuff X<thingZ<>>baz>\n"),
181  join "\n",
182
183  '<Document>',
184  '  <Para>',
185  '    <F>',
186  '      <C>',
187  '        fo',
188  '        <L content-implicit="yes" raw="E&#60;78&#62;et::Ping/Ping-E&#60;112&#62;ong" section="Ping-pong" to="Net::Ping" type="pod">',
189  '          &#34;Ping-pong&#34; in Net::Ping',
190  '        </L>',
191  '        o',
192  '      </C>',
193  '      ',
194  '      <I>',
195  '        bar',
196  '      </I>',
197  '    </F>',
198  '    ',
199  '    <B>',
200  '      stuff baz',
201  '    </B>',
202  '  </Para>',
203  '</Document>',
204  '',
205);
206
207#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208
209
210
211print "# Wrapping up... one for the road...\n";
212ok 1;
213print "# --- Done with ", __FILE__, " --- \n";
214
215