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 ' foo', 48 ' </C>', 49 ' ', 50 ' <I>', 51 ' bar', 52 ' </I>', 53 ' </F>', 54 ' ', 55 ' <B>', 56 ' stuff ', 57 ' <X>', 58 ' thing', 59 ' </X>', 60 ' baz', 61 ' </B>', 62 ' </Para>', 63 '</Document>', 64 '', 65); 66 67#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 69print "# with just X-nixing...\n"; 70 71ok( Pod::Simple::DumpAsXML->_out( \&nixy, "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"), 72 join "\n", 73 74 '<Document>', 75 ' <Para>', 76 ' <F>', 77 ' <C>', 78 ' foo', 79 ' </C>', 80 ' ', 81 ' <I>', 82 ' bar', 83 ' </I>', 84 ' </F>', 85 ' ', 86 ' <B>', 87 ' stuff baz', 88 ' </B>', 89 ' </Para>', 90 '</Document>', 91 '', 92); 93 94#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 95 96print "# With merging...\n"; 97 98ok( Pod::Simple::DumpAsXML->_out( \&mergy, "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"), 99 join "\n", 100 101 '<Document>', 102 ' <Para>', 103 ' <F>', 104 ' <C>', 105 ' foo', 106 ' </C>', 107 ' ', 108 ' <I>', 109 ' bar', 110 ' </I>', 111 ' </F>', 112 ' ', 113 ' <B>', 114 ' stuff ', 115 ' <X>', 116 ' thing', 117 ' </X>', 118 ' baz', 119 ' </B>', 120 ' </Para>', 121 '</Document>', 122 '', 123); 124 125#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 126 127print "# With nixing and merging...\n"; 128#$d = 10; 129ok( Pod::Simple::DumpAsXML->_out( \&nixy_mergy, "=pod\n\nZ<>F<C<Z<>fE<111>o> I<bar>> B<stuff X<thingZ<>>baz>\n"), 130 join "\n", 131 132 '<Document>', 133 ' <Para>', 134 ' <F>', 135 ' <C>', 136 ' foo', 137 ' </C>', 138 ' ', 139 ' <I>', 140 ' bar', 141 ' </I>', 142 ' </F>', 143 ' ', 144 ' <B>', 145 ' stuff baz', 146 ' </B>', 147 ' </Para>', 148 '</Document>', 149 '', 150); 151 152#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 153 154# Now the scary bits... with L's! 155print "# A wee L<...> sanity test...\n"; 156ok( Pod::Simple::XMLOutStream->_out(qq{=pod\n\nL<E<78>et::Ping/Ping-E<112>ong>\n}), 157 '<Document><Para><L content-implicit="yes" raw="E<78>et::Ping/Ping-E<112>ong" section="Ping-pong" to="Net::Ping" type="pod">"Ping-pong" in Net::Ping</L></Para></Document>' 158); 159print "# Now a wee L<...> with mergy...\n"; 160 161$d = 10; 162 163ok( Pod::Simple::DumpAsXML->_out(\&mergy, qq{=pod\n\nL<E<78>et::Ping/Ping-E<112>ong>\n}), 164 join "\n", 165 166 '<Document>', 167 ' <Para>', 168 ' <L content-implicit="yes" raw="E<78>et::Ping/Ping-E<112>ong" section="Ping-pong" to="Net::Ping" type="pod">', 169 ' "Ping-pong" in Net::Ping', 170 ' </L>', 171 ' </Para>', 172 '</Document>', 173 '' 174); 175 176 177print "# Now a complex tree with L's, with nixy+mergy...\n"; 178 179ok( 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"), 180 join "\n", 181 182 '<Document>', 183 ' <Para>', 184 ' <F>', 185 ' <C>', 186 ' fo', 187 ' <L content-implicit="yes" raw="E<78>et::Ping/Ping-E<112>ong" section="Ping-pong" to="Net::Ping" type="pod">', 188 ' "Ping-pong" in Net::Ping', 189 ' </L>', 190 ' o', 191 ' </C>', 192 ' ', 193 ' <I>', 194 ' bar', 195 ' </I>', 196 ' </F>', 197 ' ', 198 ' <B>', 199 ' stuff baz', 200 ' </B>', 201 ' </Para>', 202 '</Document>', 203 '', 204); 205 206#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 207 208 209 210print "# Wrapping up... one for the road...\n"; 211ok 1; 212print "# --- Done with ", __FILE__, " --- \n"; 213 214