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