Commit | Line | Data |
---|---|---|
f011ec7d | 1 | #!/usr/bin/perl -w |
e2a52b10 | 2 | # $Id: text.t,v 1.5 2006-01-28 22:31:50 eagle Exp $ |
f011ec7d JH |
3 | # |
4 | # text.t -- Additional specialized tests for Pod::Text. | |
5 | # | |
e2a52b10 | 6 | # Copyright 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu> |
f011ec7d JH |
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; | |
b7ae008f | 20 | print "1..3\n"; |
f011ec7d JH |
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 | ||
8f202758 | 32 | my $parser = Pod::Text->new or die "Cannot create parser\n"; |
f011ec7d JH |
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; | |
e2a52b10 SP |
42 | open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; |
43 | $parser->parse_from_file ('tmp.pod', \*OUT); | |
44 | close OUT; | |
f011ec7d JH |
45 | open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; |
46 | my $output; | |
47 | { | |
48 | local $/; | |
49 | $output = <TMP>; | |
50 | } | |
51 | close TMP; | |
52 | unlink ('tmp.pod', 'out.tmp'); | |
53 | my $expected = ''; | |
54 | while (<DATA>) { | |
55 | last if $_ eq "###\n"; | |
56 | $expected .= $_; | |
57 | } | |
58 | if ($output eq $expected) { | |
59 | print "ok $n\n"; | |
60 | } else { | |
61 | print "not ok $n\n"; | |
62 | print "Expected\n========\n$expected\nOutput\n======\n$output\n"; | |
63 | } | |
64 | $n++; | |
65 | } | |
66 | ||
67 | # Below the marker are bits of POD and corresponding expected text output. | |
68 | # This is used to test specific features or problems with Pod::Text. The | |
69 | # input and output are separated by lines containing only ###. | |
70 | ||
71 | __DATA__ | |
72 | ||
73 | ### | |
74 | =head1 PERIODS | |
75 | ||
76 | This C<.> should be quoted. | |
77 | ### | |
78 | PERIODS | |
79 | This "." should be quoted. | |
80 | ||
81 | ### | |
b7ae008f SP |
82 | |
83 | ### | |
84 | =head1 CE<lt>E<gt> WITH SPACES | |
85 | ||
86 | What does C<< this. >> end up looking like? | |
87 | ### | |
88 | C<> WITH SPACES | |
89 | What does "this." end up looking like? | |
90 | ||
91 | ### |