1use strict; 2use warnings; 3use 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 11use Pod::Simple::PullParser; 12 13#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14########################################################################### 15 16{ 17print "# Testing another set, at line ", __LINE__, "\n"; 18 19my $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 22ok $p->get_title(), 'Bzorch'; 23 24my $t; 25 26ok( $t = $p->get_token); 27is( $t && $t->type, 'start'); 28is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 29 30ok( $t = $p->get_token); 31is( $t && $t->type, 'start'); 32is( $t && $t->type eq 'start' && $t->tagname, 'head1' ); 33 34ok( $t = $p->get_token); 35is( $t && $t->type, 'text'); 36is( $t && $t->type eq 'text' && $t->text, 'NAME' ); 37 38DIE: { 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{ 50print "# Testing a set with nocase, at line ", __LINE__, "\n"; 51my $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 54ok $p->get_title(nocase => 1), 'Shazbot'; 55 56ok( my $t = $p->get_token); 57is( $t && $t->type, 'start'); 58is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 59 60ok( $t = $p->get_token); 61is( $t && $t->type, 'start'); 62is( $t && $t->type eq 'start' && $t->tagname, 'head1' ); 63 64ok( $t = $p->get_token); 65is( $t && $t->type, 'text'); 66is( $t && $t->type eq 'text' && $t->text, 'Name' ); 67 68} 69 70########################################################################### 71 72{ 73print "# Testing another set, at line ", __LINE__, "\n"; 74 75my $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 78ok $p->get_title(), 'Bzorch'; 79my $t; 80 81ok( $t = $p->get_token); 82is( $t && $t->type, 'start'); 83is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 84 85ok( $t = $p->get_token); 86is( $t && $t->type, 'start'); 87is( $t && $t->type eq 'start' && $t->tagname, 'head1' ); 88 89ok( $t = $p->get_token); 90is( $t && $t->type, 'text'); 91 92} 93 94 95########################################################################### 96 97{ 98print "# Testing another set, at line ", __LINE__, "\n"; 99 100{ 101my $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} ); 103is $p->get_title(), 'Bzorch - thing lala'; 104} 105 106 107my $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} ); 109is $p->get_title(), 'Bzorch - thing lala'; 110 111my $t; 112 113ok( $t = $p->get_token); 114is( $t && $t->type, 'start'); 115is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 116 117ok( $t = $p->get_token); 118is( $t && $t->type, 'start'); 119is( $t && $t->type eq 'start' && $t->tagname, 'head1' ); 120 121ok( $t = $p->get_token); 122is( $t && $t->type, 'text'); 123is( $t && $t->type eq 'text' && $t->text, 'NAME' ); 124 125} 126 127########################################################################### 128 129{ 130print "# Testing another set, at line ", __LINE__, "\n"; 131 132my $p = Pod::Simple::PullParser->new; 133$p->set_source( \qq{\n=head1 Bzorch lala\n\n=pod\n\nLala\n\n\=cut\n} ); 134 135is $p->get_title(), 'Bzorch lala'; 136my $t; 137 138ok( $t = $p->get_token); 139is( $t && $t->type, 'start'); 140is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 141 142ok( $t = $p->get_token); 143is( $t && $t->type, 'start'); 144is( $t && $t->type eq 'start' && $t->tagname, 'head1' ); 145 146ok( $t = $p->get_token); 147is( $t && $t->type, 'text'); 148is( $t && $t->type eq 'text' && $t->text, 'Bzorch lala' ); 149 150} 151 152########################################################################### 153 154{ 155print "# Testing another set, at line ", __LINE__, "\n"; 156 157my $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 160is $p->get_title(), 'Bzorch - thing lala'; 161my $t; 162 163ok( $t = $p->get_token); 164is( $t && $t->type, 'start'); 165is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 166 167ok( $t = $p->get_token); 168is( $t && $t->type, 'start'); 169is( $t && $t->type eq 'start' && $t->tagname, 'head1' ); 170 171ok( $t = $p->get_token); 172is( $t && $t->type, 'text'); 173is( $t && $t->type eq 'text' && $t->text, 'Bzorch - ' ); 174 175} 176########################################################################### 177 178{ 179print "# Testing another set, at line ", __LINE__, "\n"; 180 181my $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 184is $p->get_version || '', ''; 185is $p->get_author || '', ''; 186 187ok $p->get_title(), 'Bzorch - thing lala'; 188 189my $t; 190ok( $t = $p->get_token); 191ok( $t && $t->type, 'start'); 192ok( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 193 194} 195########################################################################### 196 197{ 198print "# Testing another set, at line ", __LINE__, "\n"; 199 200my $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 203ok $p->get_title(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 204my $t; 205 206ok( $t = $p->get_token); 207is( $t && $t->type, 'start'); 208is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 209 210} 211 212########################################################################### 213 214{ 215print "# Testing another set, at line ", __LINE__, "\n"; 216 217my $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 220is $p->get_title(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 221my $t; 222 223ok( $t = $p->get_token); 224is( $t && $t->type, 'start'); 225is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 226 227} 228 229########################################################################### 230 231{ 232print "# Testing another set, at line ", __LINE__, "\n"; 233 234my $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 237is $p->get_title() || '', ''; 238is $p->get_description(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 239my $t; 240 241ok( $t = $p->get_token); 242is( $t && $t->type, 'start'); 243is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 244 245} 246########################################################################### 247 248{ 249print "# Testing another set, at line ", __LINE__, "\n"; 250 251my $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 254is $p->get_description(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 255is $p->get_title() || '', ''; 256my $t; 257 258ok( $t = $p->get_token); 259is( $t && $t->type, 'start'); 260is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 261 262} 263 264########################################################################### 265 266{ 267print "# Testing another set, at line ", __LINE__, "\n"; 268 269my $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 272is $p->get_description(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 273is $p->get_title(), "Thingy"; 274my $t; 275 276ok( $t = $p->get_token); 277is( $t && $t->type, 'start'); 278is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 279 280} 281 282########################################################################### 283 284{ 285print "# Testing another set, at line ", __LINE__, "\n"; 286 287my $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 290is $p->get_title(), "Thingy"; 291is $p->get_description(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 292my $t; 293 294ok( $t = $p->get_token); 295is( $t && $t->type, 'start'); 296is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 297 298} 299 300########################################################################### 301 302{ 303print "# Testing another set, at line ", __LINE__, "\n"; 304 305my $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 308is $p->get_title(), "Thingy"; 309is $p->get_description(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 310my $t; 311 312ok( $t = $p->get_token); 313is( $t && $t->type, 'start'); 314is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 315 316} 317 318########################################################################### 319 320{ 321print "# Testing another set, at line ", __LINE__, "\n"; 322 323my $p = Pod::Simple::PullParser->new; 324$p->set_source( \q{ 325 326=head1 (NAME) ����� ����� 327 328Thingy 329 330=head1 (DESCRIPTION) ����� ������ 331 332����� ������ �� ����������� ������ -- Fet's I<"When you were> reading 333 334=pod 335 336Grunk 337 338=cut 339} ); 340 341is $p->get_title(), "Thingy"; 342is $p->get_version() || '', ''; 343is $p->get_description(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 344my $t; 345 346ok( $t = $p->get_token); 347is( $t && $t->type, 'start'); 348is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 349 350} 351 352########################################################################### 353 354{ 355print "# Testing another set, at line ", __LINE__, "\n"; 356 357my $p = Pod::Simple::PullParser->new; 358$p->set_source( \q{ 359 360=head1 (NAME) ����� ����� 361 362Thingy 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 375Jojoj E<65>arzarz 376 377=pod 378 379Grunk 380 381=cut 382} ); 383 384is $p->get_title(), "Thingy"; 385my $v = $p->get_version || ''; 386$v =~ s/^ +//m; 387$v =~ s/^\s+//s; 388$v =~ s/\s+$//s; 389is $v, "Stuff: Thing\nWhatever: Um."; 390is $p->get_description(), q{����� ������ �� ����������� ������ -- Fet's "When you were reading}; 391is $p->get_author() || '', 'Jojoj Aarzarz'; 392 393 394my $t; 395ok( $t = $p->get_token); 396is( $t && $t->type, 'start'); 397is( $t && $t->type eq 'start' && $t->tagname, 'Document' ); 398 399} 400 401########################################################################### 402{ 403print "# Testing a title with an X<>, at line ", __LINE__, "\n"; 404my $p = Pod::Simple::PullParser->new; 405$p->set_source( \qq{\n=head1 NAME Foo Bar\nX<Some entry>\n} ); 406 407is $p->get_title(), 'NAME Foo Bar'; 408} 409