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 / verb_fmt.t
CommitLineData
9c7c0c6c 1# Testing verbatim formatted sections
351625bd
SP
2use strict;
3use Test;
4BEGIN { plan tests => 62 };
5
6#use Pod::Simple::Debug (6);
7
8ok 1;
9
10use Pod::Simple::DumpAsXML;
11use Pod::Simple::XMLOutStream;
12
13print "# Pod::Simple version $Pod::Simple::VERSION\n";
14sub e ($$) { Pod::Simple::DumpAsXML->_duo(\&without_vf, @_) }
15sub ev ($$) { Pod::Simple::DumpAsXML->_duo(\&with_vf, @_) }
16
17sub with_vf { $_[0]-> accept_codes('VerbatimFormatted') }
18sub without_vf { $_[0]->unaccept_codes('VerbatimFormatted') }
19
20# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
21
22print "# 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,
31q{=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,
44q{=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,
57q{=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,
69q{=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,
78q{=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,
87q{=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,
96q{=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:
107q{=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,
118q{=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,
127q{=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
145print "# Now running some tests adapted from verbatims.t...\n#\n#\n";
146
147print "# 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" );
152print "# 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
159print "# Now testing via XMLOutStream without VerbatimFormatted...\n";
160
161ok( 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);
164ok( 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);
167ok( 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
171print "# Contiguous verbatims...\n";
172ok( 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);
175ok( 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
179print "# Testing =cut...\n";
180ok( 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
187print "#\n# Now retesting with VerbatimFormatted...\n";
188
189ok( 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);
192ok( 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);
195ok( 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
199print "# Contiguous verbatims...\n";
200ok( 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);
203ok( 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
207print "# Testing =cut...\n";
208ok( 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{
218my $it =
219qq{<Document><Verbatim\nxml:space="preserve"> foo bar baz</Verbatim><head1>Foo</head1><Verbatim\nxml:space="preserve"> quux\nquum</Verbatim></Document>}
220;
221
222
223print "# Various \\n-(in)significance sanity checks...\n";
224
225print "# verbatim/cut/head/verbatim sanity zero...\n";
226
227ok( Pod::Simple::XMLOutStream->_out(\&without_vf, "\n=pod\n\n foo bar baz\n\n=head1 Foo\n\n quux\nquum\n"), $it);
228ok( 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);
229ok( 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
231print "# verbatim/cut/head/verbatim sanity one...\n";
232
233ok( 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);
234ok( 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);
235ok( 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
237print "# verbatim/cut/head/verbatim sanity two...\n";
238
239ok( 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);
240ok( 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);
241ok( 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
243print "# verbatim/cut/head/verbatim sanity three...\n";
244
245ok( 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);
246ok( 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);
247ok( 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
249print "# verbatim/cut/head/verbatim sanity four...\n";
250
251ok( 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);
252ok( 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);
253ok( 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
260print "#\n# Now retesting with VerbatimFormatted...\n";
261
262{
263my $it =
264qq{<Document><VerbatimFormatted\nxml:space="preserve"> foo bar baz</VerbatimFormatted><head1>Foo</head1><VerbatimFormatted\nxml:space="preserve"> quux\nquum</VerbatimFormatted></Document>}
265;
266
267
268print "# Various \\n-(in)significance sanity checks...\n";
269
270print "# verbatim/cut/head/verbatim sanity zero...\n";
271
272ok( Pod::Simple::XMLOutStream->_out(\&with_vf, "\n=pod\n\n foo bar baz\n\n=head1 Foo\n\n quux\nquum\n"), $it);
273ok( 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);
274ok( 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
276print "# verbatim/cut/head/verbatim sanity one...\n";
277
278ok( 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);
279ok( 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);
280ok( 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
282print "# verbatim/cut/head/verbatim sanity two...\n";
283
284ok( 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);
285ok( 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);
286ok( 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
288print "# verbatim/cut/head/verbatim sanity three...\n";
289
290ok( 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);
291ok( 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);
292ok( 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
294print "# verbatim/cut/head/verbatim sanity four...\n";
295
296ok( 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);
297ok( 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);
298ok( 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
304print "# Wrapping up... one for the road...\n";
305ok 1;
306print "# --- Done with ", __FILE__, " --- \n";
307
308