Commit | Line | Data |
f011ec7d |
1 | #!/usr/bin/perl -w |
f011ec7d |
2 | # |
3 | # text.t -- Additional specialized tests for Pod::Text. |
4 | # |
9d1cda07 |
5 | # Copyright 2002, 2004, 2006, 2007, 2008, 2009 Russ Allbery <rra@stanford.edu> |
f011ec7d |
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'; |
f011ec7d |
14 | } |
15 | unshift (@INC, '../blib/lib'); |
16 | $| = 1; |
f011ec7d |
17 | } |
18 | |
fe61459e |
19 | use strict; |
f011ec7d |
20 | |
40dcca8a |
21 | use Pod::Simple; |
fe61459e |
22 | use Test::More tests => 8; |
23 | BEGIN { use_ok ('Pod::Text') } |
f011ec7d |
24 | |
fe61459e |
25 | my $parser = Pod::Text->new; |
26 | isa_ok ($parser, 'Pod::Text', 'Parser object'); |
27 | my $n = 1; |
f011ec7d |
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; |
e2a52b10 |
36 | open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; |
37 | $parser->parse_from_file ('tmp.pod', \*OUT); |
38 | close OUT; |
f011ec7d |
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; |
fe61459e |
46 | 1 while unlink ('tmp.pod', 'out.tmp'); |
f011ec7d |
47 | my $expected = ''; |
48 | while (<DATA>) { |
49 | last if $_ eq "###\n"; |
50 | $expected .= $_; |
51 | } |
fe61459e |
52 | is ($output, $expected, "Output correct for test $n"); |
f011ec7d |
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 | ### |
b7ae008f |
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 | ### |
40dcca8a |
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. |
3fe752ba |
89 | |
40dcca8a |
90 | ### |
eccdc4d7 |
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 | ### |
9d1cda07 |
118 | |
119 | ### |
120 | =pod |
121 | |
122 | text |
123 | |
124 | line1 |
125 | |
126 | line3 |
127 | ### |
128 | text |
129 | |
130 | line1 |
131 | |
132 | line3 |
133 | |
134 | ### |
fe61459e |
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 | ### |