This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Pod-Simple to CPAN version 3.18
[perl5.git] / cpan / Pod-Simple / t / x_nixer.t
1
2
3 use strict;
4 use Test;
5 BEGIN { plan tests => 11 };
6
7 my $d;
8 #use Pod::Simple::Debug (\$d, 0);
9
10 ok 1;
11
12 use Pod::Simple::XMLOutStream;
13 use Pod::Simple::DumpAsXML;
14
15
16 $Pod::Simple::XMLOutStream::ATTR_PAD   = ' ';
17 $Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output
18
19
20 print "# A simple sanity test...\n";
21 ok( 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
25 print "# With lots of nesting, and Z's...\n";
26 ok( 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
32 sub mergy {$_[0]->merge_text(1)}
33 sub nixy  {$_[0]->nix_X_codes(1)}
34 sub nixy_mergy {$_[0]->merge_text(1); $_[0]->nix_X_codes(1);}
35
36 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37
38 print "# With no F/X\n";
39
40 ok( 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
71 print "#  with just X-nixing...\n";
72
73 ok( 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
101 print "# With merging...\n";
102
103 ok( 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
132 print "# With nixing and merging...\n";
133 #$d = 10;
134 ok( 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!
160 print "# A wee L<...> sanity test...\n";
161 ok( 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 );
164 print "# Now a wee L<...> with mergy...\n";
165
166 $d = 10;
167
168 ok( 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
182 print "# Now a complex tree with L's, with nixy+mergy...\n";
183
184 ok( 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
215 print "# Wrapping up... one for the road...\n";
216 ok 1;
217 print "# --- Done with ", __FILE__, " --- \n";
218