Actually note that Shell.pm is deprecated for 5.13 and 5.14, so we can
[p5sagit/p5-mst-13.2.git] / cpan / podlators / t / text.t
1 #!/usr/bin/perl -w
2 #
3 # text.t -- Additional specialized tests for Pod::Text.
4 #
5 # Copyright 2002, 2004, 2006, 2007, 2008, 2009 Russ Allbery <rra@stanford.edu>
6 #
7 # This program is free software; you may redistribute it and/or modify it
8 # under the same terms as Perl itself.
9
10 BEGIN {
11     chdir 't' if -d 't';
12     if ($ENV{PERL_CORE}) {
13         @INC = '../lib';
14     }
15     unshift (@INC, '../blib/lib');
16     $| = 1;
17 }
18
19 use strict;
20
21 use Pod::Simple;
22 use Test::More tests => 8;
23 BEGIN { use_ok ('Pod::Text') }
24
25 my $parser = Pod::Text->new;
26 isa_ok ($parser, 'Pod::Text', 'Parser object');
27 my $n = 1;
28 while (<DATA>) {
29     next until $_ eq "###\n";
30     open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
31     while (<DATA>) {
32         last if $_ eq "###\n";
33         print TMP $_;
34     }
35     close TMP;
36     open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
37     $parser->parse_from_file ('tmp.pod', \*OUT);
38     close OUT;
39     open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
40     my $output;
41     {
42         local $/;
43         $output = <TMP>;
44     }
45     close TMP;
46     1 while unlink ('tmp.pod', 'out.tmp');
47     my $expected = '';
48     while (<DATA>) {
49         last if $_ eq "###\n";
50         $expected .= $_;
51     }
52     is ($output, $expected, "Output correct for test $n");
53     $n++;
54 }
55
56 # Below the marker are bits of POD and corresponding expected text output.
57 # This is used to test specific features or problems with Pod::Text.  The
58 # input and output are separated by lines containing only ###.
59
60 __DATA__
61
62 ###
63 =head1 PERIODS
64
65 This C<.> should be quoted.
66 ###
67 PERIODS
68     This "." should be quoted.
69
70 ###
71
72 ###
73 =head1 CE<lt>E<gt> WITH SPACES
74
75 What does C<<  this.  >> end up looking like?
76 ###
77 C<> WITH SPACES
78     What does "this." end up looking like?
79
80 ###
81
82 ###
83 =head1 Test of SE<lt>E<gt>
84
85 This is some S<  > whitespace.
86 ###
87 Test of S<>
88     This is some    whitespace.
89
90 ###
91
92 ###
93 =head1 Test of =for
94
95 =for comment
96 This won't be seen.
97
98 Yes.
99
100 =for text
101 This should be seen.
102
103 =for TEXT As should this.
104
105 =for man
106 But this shouldn't.
107
108 Some more text.
109 ###
110 Test of =for
111     Yes.
112
113 This should be seen.
114 As should this.
115     Some more text.
116
117 ###
118
119 ###
120 =pod
121
122 text
123
124   line1
125   
126   line3
127 ###
128     text
129
130       line1
131   
132       line3
133
134 ###
135
136 ###
137 =head1 LINK TO URL
138
139 This is a L<link|http://www.example.com/> to a URL.
140 ###
141 LINK TO URL
142     This is a link <http://www.example.com/> to a URL.
143
144 ###