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