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