Commit | Line | Data |
---|---|---|
9c7c0c6c | 1 | # Testing verbatim formatted sections |
351625bd SP |
2 | use strict; |
3 | use Test; | |
4 | BEGIN { plan tests => 62 }; | |
5 | ||
6 | #use Pod::Simple::Debug (6); | |
7 | ||
8 | ok 1; | |
9 | ||
10 | use Pod::Simple::DumpAsXML; | |
11 | use Pod::Simple::XMLOutStream; | |
12 | ||
13 | print "# Pod::Simple version $Pod::Simple::VERSION\n"; | |
14 | sub e ($$) { Pod::Simple::DumpAsXML->_duo(\&without_vf, @_) } | |
15 | sub ev ($$) { Pod::Simple::DumpAsXML->_duo(\&with_vf, @_) } | |
16 | ||
17 | sub with_vf { $_[0]-> accept_codes('VerbatimFormatted') } | |
18 | sub without_vf { $_[0]->unaccept_codes('VerbatimFormatted') } | |
19 | ||
20 | # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
21 | ||
22 | print "# Testing VerbatimFormatted...\n"; | |
23 | # A formatty line has to have #: in the first two columns, and uses | |
24 | # "^" to mean bold, "/" to mean underline, and "%" to mean bold italic. | |
25 | # Example: | |
26 | # What do you want? i like pie. [or whatever] | |
27 | # #:^^^^^^^^^^^^^^^^^ ///////////// | |
28 | ||
29 | ||
30 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
31 | q{=pod | |
32 | ||
33 | What do you want? i like pie. [or whatever] | |
34 | #:^^^^^^^^^^^^^^^^^ ///////////// | |
35 | Hooboy. | |
36 | ||
37 | =cut | |
38 | ||
39 | }) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i like pie. <VerbatimI>[or whatever]</VerbatimI>\n Hooboy.</VerbatimFormatted></Document>} | |
40 | ); | |
41 | ||
42 | ||
43 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
44 | q{=pod | |
45 | ||
46 | What do you want? i like pie. [or whatever] | |
47 | #:^^^^^^^^^^^^^^^^^ ///////////// | |
48 | Hooboy. | |
49 | ||
50 | =cut | |
51 | ||
52 | }) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i like pie. <VerbatimI>[or whatever]</VerbatimI>\n Hooboy.</VerbatimFormatted></Document>} | |
53 | ); | |
54 | ||
55 | ||
56 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
57 | q{=pod | |
58 | ||
59 | What do you want? i like pie. [or whatever] | |
60 | #:^^^^^^^^^^^^^^^^^ ///////////// | |
61 | ||
62 | =cut | |
63 | ||
64 | }) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i like pie. <VerbatimI>[or whatever]</VerbatimI></VerbatimFormatted></Document>} | |
65 | ); | |
66 | ||
67 | ||
68 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
69 | q{=pod | |
70 | ||
71 | What do you want? i like pie. [or whatever] | |
72 | #:^^^^^^^^^^^^^^^^^ /////////////} | |
73 | ) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i like pie. <VerbatimI>[or whatever]</VerbatimI></VerbatimFormatted></Document>} | |
74 | ); | |
75 | ||
76 | ||
77 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
78 | q{=pod | |
79 | ||
80 | What do you want? i like pie. [or whatever] | |
81 | #:^^^^^^^^^^^^^^^^^ //////////////////} | |
82 | ) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i like pie. <VerbatimI>[or whatever]</VerbatimI></VerbatimFormatted></Document>} | |
83 | ); | |
84 | ||
85 | ||
86 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
87 | q{=pod | |
88 | ||
89 | What do you want? i like pie. [or whatever] | |
90 | #:^^^^^^^^^^^^^^^^^ ///} | |
91 | ) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i like pie. <VerbatimI>[or</VerbatimI> whatever]</VerbatimFormatted></Document>} | |
92 | ); | |
93 | ||
94 | ||
95 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
96 | q{=pod | |
97 | ||
98 | What do you want? i like pie. [or whatever] | |
99 | #:^^^^^^^^^^^^^^^^^ /// | |
100 | #:^^^^^^^^^^^^^^^^^ ///} | |
101 | ) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i like pie. <VerbatimI>[or</VerbatimI> whatever]\n#:^^^^^^^^^^^^^^^^^ ///</VerbatimFormatted></Document>} | |
102 | ); | |
103 | ||
104 | ||
105 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
106 | # with a tab: | |
107 | q{=pod | |
108 | ||
109 | What do you want? i like pie. [or whatever] | |
110 | #:^^^^^^^^^^^^^^^^^ /// } | |
111 | ) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i like pie. <VerbatimI>[or</VerbatimI> whatever]</VerbatimFormatted></Document>} | |
112 | ); | |
113 | ||
114 | ||
115 | ||
116 | # Now testing the % too: | |
117 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
118 | q{=pod | |
119 | ||
120 | What do you want? i like pie. [or whatever] | |
121 | #:^^^^^^^^^^^^^^^^^ %%%% //////////////////} | |
122 | ) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> <VerbatimB>What do you want?</VerbatimB> i <VerbatimBI>like</VerbatimBI> pie. <VerbatimI>[or whatever]</VerbatimI></VerbatimFormatted></Document>} | |
123 | ); | |
124 | ||
125 | ||
126 | &ok( Pod::Simple::XMLOutStream->_out(\&with_vf, | |
127 | q{=pod | |
128 | ||
129 | Hooboy! | |
130 | What do you want? i like pie. [or whatever] | |
131 | #: ^^^^^ %%%% //////////////////} | |
132 | ) => qq{<Document><VerbatimFormatted\nxml:space="preserve"> Hooboy!\n What do you <VerbatimB>want?</VerbatimB> i <VerbatimBI>like</VerbatimBI> pie. <VerbatimI>[or whatever]</VerbatimI></VerbatimFormatted></Document>} | |
133 | ); | |
134 | ||
135 | ||
136 | ||
137 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
138 | ||
139 | ||
140 | ||
141 | ||
142 | ||
143 | # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
144 | ||
145 | print "# Now running some tests adapted from verbatims.t...\n#\n#\n"; | |
146 | ||
147 | print "# Without VerbatimFormatted...\n"; | |
148 | &ok( e "", "" ); | |
149 | &ok( e "\n", "", ); | |
150 | &ok( e "\n=pod\n\n foo bar baz", "\n=pod\n\n foo bar baz" ); | |
151 | &ok( e "\n=pod\n\n foo bar baz", "\n=pod\n\n foo bar baz\n" ); | |
152 | print "# With VerbatimFormatted...\n"; | |
153 | &ok( ev "", "" ); | |
154 | &ok( ev "\n", "", ); | |
155 | &ok( ev "\n=pod\n\n foo bar baz", "\n=pod\n\n foo bar baz" ); | |
156 | &ok( ev "\n=pod\n\n foo bar baz", "\n=pod\n\n foo bar baz\n" ); | |
157 | ||
158 | ||
159 | print "# Now testing via XMLOutStream without VerbatimFormatted...\n"; | |
160 | ||
161 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n"), | |
162 | qq{<Document><Verbatim\nxml:space="preserve"> foo bar baz</Verbatim></Document>} | |
163 | ); | |
164 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n quux\n"), | |
165 | qq{<Document><Verbatim\nxml:space="preserve"> foo bar baz\n quux</Verbatim></Document>} | |
166 | ); | |
167 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\nquux\n"), | |
168 | qq{<Document><Verbatim\nxml:space="preserve"> foo bar baz\nquux</Verbatim></Document>} | |
169 | ); | |
170 | ||
171 | print "# Contiguous verbatims...\n"; | |
172 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n quux\n"), | |
173 | qq{<Document><Verbatim\nxml:space="preserve"> foo bar baz\n\n quux</Verbatim></Document>} | |
174 | ); | |
175 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n\n quux\n"), | |
176 | qq{<Document><Verbatim\nxml:space="preserve"> foo bar baz\n\n\n quux</Verbatim></Document>} | |
177 | ); | |
178 | ||
179 | print "# Testing =cut...\n"; | |
180 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n=cut\n quux\n"), | |
181 | qq{<Document><Verbatim\nxml:space="preserve"> foo bar baz</Verbatim></Document>} | |
182 | ); | |
183 | ||
184 | ||
185 | ||
186 | ||
187 | print "#\n# Now retesting with VerbatimFormatted...\n"; | |
188 | ||
189 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n"), | |
190 | qq{<Document><VerbatimFormatted\nxml:space="preserve"> foo bar baz</VerbatimFormatted></Document>} | |
191 | ); | |
192 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n quux\n"), | |
193 | qq{<Document><VerbatimFormatted\nxml:space="preserve"> foo bar baz\n quux</VerbatimFormatted></Document>} | |
194 | ); | |
195 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\nquux\n"), | |
196 | qq{<Document><VerbatimFormatted\nxml:space="preserve"> foo bar baz\nquux</VerbatimFormatted></Document>} | |
197 | ); | |
198 | ||
199 | print "# Contiguous verbatims...\n"; | |
200 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n quux\n"), | |
201 | qq{<Document><VerbatimFormatted\nxml:space="preserve"> foo bar baz\n\n quux</VerbatimFormatted></Document>} | |
202 | ); | |
203 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n\n quux\n"), | |
204 | qq{<Document><VerbatimFormatted\nxml:space="preserve"> foo bar baz\n\n\n quux</VerbatimFormatted></Document>} | |
205 | ); | |
206 | ||
207 | print "# Testing =cut...\n"; | |
208 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n=cut\n quux\n"), | |
209 | qq{<Document><VerbatimFormatted\nxml:space="preserve"> foo bar baz</VerbatimFormatted></Document>} | |
210 | ); | |
211 | ||
212 | ||
213 | ||
214 | ||
215 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
216 | ||
217 | { | |
218 | my $it = | |
219 | qq{<Document><Verbatim\nxml:space="preserve"> foo bar baz</Verbatim><head1>Foo</head1><Verbatim\nxml:space="preserve"> quux\nquum</Verbatim></Document>} | |
220 | ; | |
221 | ||
222 | ||
223 | print "# Various \\n-(in)significance sanity checks...\n"; | |
224 | ||
225 | print "# verbatim/cut/head/verbatim sanity zero...\n"; | |
226 | ||
227 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
228 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n=cut\nsome code here...\n=head1 Foo\n\n quux\nquum\n"), $it); | |
229 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n=cut\nsome code here...\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
230 | ||
231 | print "# verbatim/cut/head/verbatim sanity one...\n"; | |
232 | ||
233 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n=cut\n\nsome code here...\n=head1 Foo\n\n quux\nquum\n"), $it); | |
234 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n=cut\nsome code here...\n=head1 Foo\n\n quux\nquum\n"), $it); | |
235 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n=cut\n\nsome code here...\n=head1 Foo\n\n quux\nquum\n"), $it); | |
236 | ||
237 | print "# verbatim/cut/head/verbatim sanity two...\n"; | |
238 | ||
239 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n=cut\n\nsome code here...\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
240 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n=cut\nsome code here...\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
241 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n=cut\n\n\nsome code here...\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
242 | ||
243 | print "# verbatim/cut/head/verbatim sanity three...\n"; | |
244 | ||
245 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n=cut\n\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
246 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n=cut\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
247 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n=cut\n\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
248 | ||
249 | print "# verbatim/cut/head/verbatim sanity four...\n"; | |
250 | ||
251 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n\n\n\n=cut\n\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
252 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n\n\n\n\n=cut\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
253 | ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n\n\n\n\n=cut\n\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
254 | ||
255 | } | |
256 | ||
257 | ||
258 | # : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : | |
259 | ||
260 | print "#\n# Now retesting with VerbatimFormatted...\n"; | |
261 | ||
262 | { | |
263 | my $it = | |
264 | qq{<Document><VerbatimFormatted\nxml:space="preserve"> foo bar baz</VerbatimFormatted><head1>Foo</head1><VerbatimFormatted\nxml:space="preserve"> quux\nquum</VerbatimFormatted></Document>} | |
265 | ; | |
266 | ||
267 | ||
268 | print "# Various \\n-(in)significance sanity checks...\n"; | |
269 | ||
270 | print "# verbatim/cut/head/verbatim sanity zero...\n"; | |
271 | ||
272 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
273 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n=cut\nsome code here...\n=head1 Foo\n\n quux\nquum\n"), $it); | |
274 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n=cut\nsome code here...\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
275 | ||
276 | print "# verbatim/cut/head/verbatim sanity one...\n"; | |
277 | ||
278 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n=cut\n\nsome code here...\n=head1 Foo\n\n quux\nquum\n"), $it); | |
279 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n=cut\nsome code here...\n=head1 Foo\n\n quux\nquum\n"), $it); | |
280 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n=cut\n\nsome code here...\n=head1 Foo\n\n quux\nquum\n"), $it); | |
281 | ||
282 | print "# verbatim/cut/head/verbatim sanity two...\n"; | |
283 | ||
284 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n=cut\n\nsome code here...\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
285 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n=cut\nsome code here...\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
286 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n=cut\n\n\nsome code here...\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
287 | ||
288 | print "# verbatim/cut/head/verbatim sanity three...\n"; | |
289 | ||
290 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n=cut\n\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
291 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n=cut\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
292 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n=cut\n\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
293 | ||
294 | print "# verbatim/cut/head/verbatim sanity four...\n"; | |
295 | ||
296 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n\n\n\n=cut\n\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
297 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n\n\n\n\n=cut\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
298 | ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n\n\n\n\n=cut\n\nsome code here...\n\n\n=head1 Foo\n\n quux\nquum\n"), $it); | |
299 | ||
300 | } | |
301 | ||
302 | ||
303 | ||
304 | print "# Wrapping up... one for the road...\n"; | |
305 | ok 1; | |
306 | print "# --- Done with ", __FILE__, " --- \n"; | |
307 | ||
308 |