Upgrade to podlators 2.0.6
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / text.t
1 #!/usr/bin/perl -w
2 # $Id: text.t,v 1.6 2007-09-12 00:20:08 eagle Exp $
3 #
4 # text.t -- Additional specialized tests for Pod::Text.
5 #
6 # Copyright 2002, 2004, 2006, 2007 by Russ Allbery <rra@stanford.edu>
7 #
8 # This program is free software; you may redistribute it and/or modify it
9 # under the same terms as Perl itself.
10
11 BEGIN {
12     chdir 't' if -d 't';
13     if ($ENV{PERL_CORE}) {
14         @INC = '../lib';
15     } else {
16         unshift (@INC, '../blib/lib');
17     }
18     unshift (@INC, '../blib/lib');
19     $| = 1;
20     print "1..4\n";
21 }
22
23 END {
24     print "not ok 1\n" unless $loaded;
25 }
26
27 use Pod::Text;
28 use Pod::Simple;
29
30 $loaded = 1;
31 print "ok 1\n";
32
33 my $parser = Pod::Text->new or die "Cannot create parser\n";
34 my $n = 2;
35 while (<DATA>) {
36     next until $_ eq "###\n";
37     open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
38     while (<DATA>) {
39         last if $_ eq "###\n";
40         print TMP $_;
41     }
42     close TMP;
43     open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
44     $parser->parse_from_file ('tmp.pod', \*OUT);
45     close OUT;
46     open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
47     my $output;
48     {
49         local $/;
50         $output = <TMP>;
51     }
52     close TMP;
53     unlink ('tmp.pod', 'out.tmp');
54     my $expected = '';
55     while (<DATA>) {
56         last if $_ eq "###\n";
57         $expected .= $_;
58     }
59     if ($output eq $expected) {
60         print "ok $n\n";
61     } elsif ($n == 4 && $Pod::Simple::VERSION < 3.06) {
62         print "ok $n # skip Pod::Simple S<> parsing bug\n";
63     } else {
64         print "not ok $n\n";
65         print "Expected\n========\n$expected\nOutput\n======\n$output\n";
66     }
67     $n++;
68 }
69
70 # Below the marker are bits of POD and corresponding expected text output.
71 # This is used to test specific features or problems with Pod::Text.  The
72 # input and output are separated by lines containing only ###.
73
74 __DATA__
75
76 ###
77 =head1 PERIODS
78
79 This C<.> should be quoted.
80 ###
81 PERIODS
82     This "." should be quoted.
83
84 ###
85
86 ###
87 =head1 CE<lt>E<gt> WITH SPACES
88
89 What does C<<  this.  >> end up looking like?
90 ###
91 C<> WITH SPACES
92     What does "this." end up looking like?
93
94 ###
95
96 ###
97 =head1 Test of SE<lt>E<gt>
98
99 This is some S<  > whitespace.
100 ###
101 Test of S<>
102     This is some    whitespace.
103 ###
104 ==