Upgrade to podlators-2.0.2
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / text.t
1 #!/usr/bin/perl -w
2 # $Id: text.t,v 1.4 2006-01-20 21:20:58 eagle Exp $
3 #
4 # text.t -- Additional specialized tests for Pod::Text.
5 #
6 # Copyright 2002, 2004 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..3\n";
21 }
22
23 END {
24     print "not ok 1\n" unless $loaded;
25 }
26
27 use Pod::Text;
28
29 $loaded = 1;
30 print "ok 1\n";
31
32 my $parser = Pod::Text->new or die "Cannot create parser\n";
33 my $n = 2;
34 while (<DATA>) {
35     next until $_ eq "###\n";
36     open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
37     while (<DATA>) {
38         last if $_ eq "###\n";
39         print TMP $_;
40     }
41     close TMP;
42     $parser->parse_from_file ('tmp.pod', 'out.tmp');
43     open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
44     my $output;
45     {
46         local $/;
47         $output = <TMP>;
48     }
49     close TMP;
50     unlink ('tmp.pod', 'out.tmp');
51     my $expected = '';
52     while (<DATA>) {
53         last if $_ eq "###\n";
54         $expected .= $_;
55     }
56     if ($output eq $expected) {
57         print "ok $n\n";
58     } else {
59         print "not ok $n\n";
60         print "Expected\n========\n$expected\nOutput\n======\n$output\n";
61     }
62     $n++;
63 }
64
65 # Below the marker are bits of POD and corresponding expected text output.
66 # This is used to test specific features or problems with Pod::Text.  The
67 # input and output are separated by lines containing only ###.
68
69 __DATA__
70
71 ###
72 =head1 PERIODS
73
74 This C<.> should be quoted.
75 ###
76 PERIODS
77     This "." should be quoted.
78
79 ###
80
81 ###
82 =head1 CE<lt>E<gt> WITH SPACES
83
84 What does C<<  this.  >> end up looking like?
85 ###
86 C<> WITH SPACES
87     What does "this." end up looking like?
88
89 ###