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