This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Pod::Simple from 3.43 to 3.45
[perl5.git] / cpan / Pod-Simple / t / pulltitl.t
1 use strict;
2 use warnings;
3 use Test::More tests => 115;
4
5 #use Pod::Simple::Debug (5);
6
7 #sub Pod::Simple::MANY_LINES () {1}
8 #sub Pod::Simple::PullParser::DEBUG () {3}
9
10
11 use Pod::Simple::PullParser;
12
13 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 ###########################################################################
15
16 {
17 print "# Testing another set, at line ", __LINE__, "\n";
18
19 my $p = Pod::Simple::PullParser->new;
20 $p->set_source( \qq{\n=head1 NAME\n\nBzorch\n\n=pod\n\nLala\n\n\=cut\n} );
21
22 ok $p->get_title(), 'Bzorch';
23
24 my $t;
25
26 ok( $t = $p->get_token);
27 is( $t && $t->type, 'start');
28 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
29
30 ok( $t = $p->get_token);
31 is( $t && $t->type, 'start');
32 is( $t && $t->type eq 'start' && $t->tagname, 'head1' );
33
34 ok( $t = $p->get_token);
35 is( $t && $t->type, 'text');
36 is( $t && $t->type eq 'text' && $t->text, 'NAME' );
37
38 DIE: {
39     # Make sure we die.
40     local $@;
41     eval { $p->set_source(\'=head1 foo') };
42     ok $@;
43     like $@, qr/\QCannot assign new source to pull parser; create a new instance, instead/;
44 }
45 }
46
47 ###########################################################################
48
49 {
50 print "# Testing a set with nocase, at line ", __LINE__, "\n";
51 my $p = Pod::Simple::PullParser->new;
52 $p->set_source( \qq{\n=head1 Name\n\nShazbot\n\n=pod\n\nLala\n\n\=cut\n} );
53
54 ok $p->get_title(nocase => 1), 'Shazbot';
55
56 ok( my $t = $p->get_token);
57 is( $t && $t->type, 'start');
58 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
59
60 ok( $t = $p->get_token);
61 is( $t && $t->type, 'start');
62 is( $t && $t->type eq 'start' && $t->tagname, 'head1' );
63
64 ok( $t = $p->get_token);
65 is( $t && $t->type, 'text');
66 is( $t && $t->type eq 'text' && $t->text, 'Name' );
67
68 }
69
70 ###########################################################################
71
72 {
73 print "# Testing another set, at line ", __LINE__, "\n";
74
75 my $p = Pod::Simple::PullParser->new;
76 $p->set_source( \qq{\n=head1 NE<65>ME\n\nBzorch\n\n=pod\n\nLala\n\n\=cut\n} );
77
78 ok $p->get_title(), 'Bzorch';
79 my $t;
80
81 ok( $t = $p->get_token);
82 is( $t && $t->type, 'start');
83 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
84
85 ok( $t = $p->get_token);
86 is( $t && $t->type, 'start');
87 is( $t && $t->type eq 'start' && $t->tagname, 'head1' );
88
89 ok( $t = $p->get_token);
90 is( $t && $t->type, 'text');
91
92 }
93
94
95 ###########################################################################
96
97 {
98 print "# Testing another set, at line ", __LINE__, "\n";
99
100 {
101 my $p = Pod::Simple::PullParser->new;
102 $p->set_source( \qq{\n=head1 NAME\n\nBzorch - I<thing> lala\n\n=pod\n\nLala\n\n\=cut\n} );
103 is $p->get_title(), 'Bzorch - thing lala';
104 }
105
106
107 my $p = Pod::Simple::PullParser->new;
108 $p->set_source( \qq{\n=head1 NAME\n\nBzorch - I<thing> lala\n\n=pod\n\nLala\n\n\=cut\n} );
109 is $p->get_title(), 'Bzorch - thing lala';
110
111 my $t;
112
113 ok( $t = $p->get_token);
114 is( $t && $t->type, 'start');
115 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
116
117 ok( $t = $p->get_token);
118 is( $t && $t->type, 'start');
119 is( $t && $t->type eq 'start' && $t->tagname, 'head1' );
120
121 ok( $t = $p->get_token);
122 is( $t && $t->type, 'text');
123 is( $t && $t->type eq 'text' && $t->text, 'NAME' );
124
125 }
126
127 ###########################################################################
128
129 {
130 print "# Testing another set, at line ", __LINE__, "\n";
131
132 my $p = Pod::Simple::PullParser->new;
133 $p->set_source( \qq{\n=head1 Bzorch lala\n\n=pod\n\nLala\n\n\=cut\n} );
134
135 is $p->get_title(), 'Bzorch lala';
136 my $t;
137
138 ok( $t = $p->get_token);
139 is( $t && $t->type, 'start');
140 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
141
142 ok( $t = $p->get_token);
143 is( $t && $t->type, 'start');
144 is( $t && $t->type eq 'start' && $t->tagname, 'head1' );
145
146 ok( $t = $p->get_token);
147 is( $t && $t->type, 'text');
148 is( $t && $t->type eq 'text' && $t->text, 'Bzorch lala' );
149
150 }
151
152 ###########################################################################
153
154 {
155 print "# Testing another set, at line ", __LINE__, "\n";
156
157 my $p = Pod::Simple::PullParser->new;
158 $p->set_source( \qq{\n=head1 Bzorch - I<thing> lala\n\n=pod\n\nLala\n\n\=cut\n} );
159
160 is $p->get_title(), 'Bzorch - thing lala';
161 my $t;
162
163 ok( $t = $p->get_token);
164 is( $t && $t->type, 'start');
165 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
166
167 ok( $t = $p->get_token);
168 is( $t && $t->type, 'start');
169 is( $t && $t->type eq 'start' && $t->tagname, 'head1' );
170
171 ok( $t = $p->get_token);
172 is( $t && $t->type, 'text');
173 is( $t && $t->type eq 'text' && $t->text, 'Bzorch - ' );
174
175 }
176 ###########################################################################
177
178 {
179 print "# Testing another set, at line ", __LINE__, "\n";
180
181 my $p = Pod::Simple::PullParser->new;
182 $p->set_source( \qq{\n=head1 Nombre (NAME)\n\nBzorch - I<thing> lala\n\n=pod\n\nGrunk\n\n\=cut\n} );
183
184 is $p->get_version || '', '';
185 is $p->get_author  || '', '';
186
187 ok $p->get_title(), 'Bzorch - thing lala';
188
189 my $t;
190 ok( $t = $p->get_token);
191 ok( $t && $t->type, 'start');
192 ok( $t && $t->type eq 'start' && $t->tagname, 'Document' );
193
194 }
195 ###########################################################################
196
197 {
198 print "# Testing another set, at line ", __LINE__, "\n";
199
200 my $p = Pod::Simple::PullParser->new;
201 $p->set_source( \qq{\n=head1 ëÏÇÄÁ ÞÉÔÁÌÁ (NAME)\n\nëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading\n\n=pod\n\nGrunk\n\n\=cut\n} );
202
203 ok $p->get_title(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
204 my $t;
205
206 ok( $t = $p->get_token);
207 is( $t && $t->type, 'start');
208 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
209
210 }
211
212 ###########################################################################
213
214 {
215 print "# Testing another set, at line ", __LINE__, "\n";
216
217 my $p = Pod::Simple::PullParser->new;
218 $p->set_source( \qq{\n=head1 (NAME) ëÏÇÄÁ ÞÉÔÁÌÁ\n\nëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading\n\n=pod\n\nGrunk\n\n\=cut\n} );
219
220 is $p->get_title(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
221 my $t;
222
223 ok( $t = $p->get_token);
224 is( $t && $t->type, 'start');
225 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
226
227 }
228
229 ###########################################################################
230
231 {
232 print "# Testing another set, at line ", __LINE__, "\n";
233
234 my $p = Pod::Simple::PullParser->new;
235 $p->set_source( \qq{\n=head1 (DESCRIPTION) ëÏÇÄÁ ÞÉÔÁÌÁ\n\nëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading\n\n=pod\n\nGrunk\n\n\=cut\n} );
236
237 is $p->get_title() || '', '';
238 is $p->get_description(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
239 my $t;
240
241 ok( $t = $p->get_token);
242 is( $t && $t->type, 'start');
243 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
244
245 }
246 ###########################################################################
247
248 {
249 print "# Testing another set, at line ", __LINE__, "\n";
250
251 my $p = Pod::Simple::PullParser->new;
252 $p->set_source( \qq{\n=head1 (DESCRIPTION) ëÏÇÄÁ ÞÉÔÁÌÁ\n\nëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading\n\n=pod\n\nGrunk\n\n\=cut\n} );
253
254 is $p->get_description(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
255 is $p->get_title() || '', '';
256 my $t;
257
258 ok( $t = $p->get_token);
259 is( $t && $t->type, 'start');
260 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
261
262 }
263
264 ###########################################################################
265
266 {
267 print "# Testing another set, at line ", __LINE__, "\n";
268
269 my $p = Pod::Simple::PullParser->new;
270 $p->set_source( \qq{\n=head1 NAME\n\nThingy\n\n=head1 (DESCRIPTION) ëÏÇÄÁ ÞÉÔÁÌÁ\n\nëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading\n\n=pod\n\nGrunk\n\n\=cut\n} );
271
272 is $p->get_description(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
273 is $p->get_title(), "Thingy";
274 my $t;
275
276 ok( $t = $p->get_token);
277 is( $t && $t->type, 'start');
278 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
279
280 }
281
282 ###########################################################################
283
284 {
285 print "# Testing another set, at line ", __LINE__, "\n";
286
287 my $p = Pod::Simple::PullParser->new;
288 $p->set_source( \qq{\n=head1 NAME\n\nThingy\n\n=head1 (DESCRIPTION) ëÏÇÄÁ ÞÉÔÁÌÁ\n\nëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading\n\n=pod\n\nGrunk\n\n\=cut\n} );
289
290 is $p->get_title(), "Thingy";
291 is $p->get_description(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
292 my $t;
293
294 ok( $t = $p->get_token);
295 is( $t && $t->type, 'start');
296 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
297
298 }
299
300 ###########################################################################
301
302 {
303 print "# Testing another set, at line ", __LINE__, "\n";
304
305 my $p = Pod::Simple::PullParser->new;
306 $p->set_source( \qq{\n=head1 (NAME) ÷ÄÁÌÉ ÐÅÒÅÄ\n\nThingy\n\n=head1 (DESCRIPTION) ëÏÇÄÁ ÞÉÔÁÌÁ\n\nëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading\n\n=pod\n\nGrunk\n\n\=cut\n} );
307
308 is $p->get_title(), "Thingy";
309 is $p->get_description(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
310 my $t;
311
312 ok( $t = $p->get_token);
313 is( $t && $t->type, 'start');
314 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
315
316 }
317
318 ###########################################################################
319
320 {
321 print "# Testing another set, at line ", __LINE__, "\n";
322
323 my $p = Pod::Simple::PullParser->new;
324 $p->set_source( \q{
325
326 =head1 (NAME) ÷ÄÁÌÉ ÐÅÒÅÄ
327
328 Thingy
329
330 =head1 (DESCRIPTION) ëÏÇÄÁ ÞÉÔÁÌÁ
331
332 ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading
333
334 =pod
335
336 Grunk
337
338 =cut
339 } );
340
341 is $p->get_title(), "Thingy";
342 is $p->get_version() || '', '';
343 is $p->get_description(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
344 my $t;
345
346 ok( $t = $p->get_token);
347 is( $t && $t->type, 'start');
348 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
349
350 }
351
352 ###########################################################################
353
354 {
355 print "# Testing another set, at line ", __LINE__, "\n";
356
357 my $p = Pod::Simple::PullParser->new;
358 $p->set_source( \q{
359
360 =head1 (NAME) ÷ÄÁÌÉ ÐÅÒÅÄ
361
362 Thingy
363
364 =head1 (DESCRIPTION) ëÏÇÄÁ ÞÉÔÁÌÁ
365
366 ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's I<"When you were> reading
367
368 =head1 VERSION
369
370   Stuff: Thing
371   Whatever: Um.
372
373 =head1 AUTHOR
374
375 Jojoj E<65>arzarz
376
377 =pod
378
379 Grunk
380
381 =cut
382 } );
383
384 is $p->get_title(), "Thingy";
385 my $v = $p->get_version || '';
386 $v =~ s/^ +//m;
387 $v =~ s/^\s+//s;
388 $v =~ s/\s+$//s;
389 is $v, "Stuff: Thing\nWhatever: Um.";
390 is $p->get_description(), q{ëÏÇÄÁ ÞÉÔÁÌÁ ÔÙ ÍÕÞÉÔÅÌØÎÙÅ ÓÔÒÏËÉ -- Fet's "When you were reading};
391 is $p->get_author() || '', 'Jojoj Aarzarz';
392
393
394 my $t;
395 ok( $t = $p->get_token);
396 is( $t && $t->type, 'start');
397 is( $t && $t->type eq 'start' && $t->tagname, 'Document' );
398
399 }
400
401 ###########################################################################
402 {
403 print "# Testing a title with an X<>, at line ", __LINE__, "\n";
404 my $p = Pod::Simple::PullParser->new;
405 $p->set_source( \qq{\n=head1 NAME Foo Bar\nX<Some entry>\n} );
406
407 is $p->get_title(), 'NAME Foo Bar';
408 }