Commit | Line | Data |
---|---|---|
b7ae008f | 1 | #!/usr/bin/perl -w |
b7ae008f SP |
2 | # |
3 | # termcap.t -- Additional specialized tests for Pod::Text::Termcap. | |
4 | # | |
e2a52b10 | 5 | # Copyright 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu> |
b7ae008f SP |
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 | } else { | |
15 | unshift (@INC, '../blib/lib'); | |
16 | } | |
17 | unshift (@INC, '../blib/lib'); | |
18 | $| = 1; | |
19 | print "1..2\n"; | |
20 | } | |
21 | ||
22 | END { | |
23 | print "not ok 1\n" unless $loaded; | |
24 | } | |
25 | ||
26 | # Hard-code a few values to try to get reproducible results. | |
27 | $ENV{COLUMNS} = 80; | |
28 | $ENV{TERM} = 'xterm'; | |
29 | $ENV{TERMCAP} = 'xterm:co=80:do=^J:md=\E[1m:us=\E[4m:me=\E[m'; | |
30 | ||
31 | use Pod::Text::Termcap; | |
32 | ||
33 | $loaded = 1; | |
34 | print "ok 1\n"; | |
35 | ||
8f202758 | 36 | my $parser = Pod::Text::Termcap->new or die "Cannot create parser\n"; |
b7ae008f SP |
37 | my $n = 2; |
38 | while (<DATA>) { | |
39 | next until $_ eq "###\n"; | |
40 | open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; | |
41 | while (<DATA>) { | |
42 | last if $_ eq "###\n"; | |
43 | print TMP $_; | |
44 | } | |
45 | close TMP; | |
e2a52b10 SP |
46 | open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; |
47 | $parser->parse_from_file ('tmp.pod', \*OUT); | |
48 | close OUT; | |
b7ae008f SP |
49 | open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; |
50 | my $output; | |
51 | { | |
52 | local $/; | |
53 | $output = <TMP>; | |
54 | } | |
55 | close TMP; | |
56 | unlink ('tmp.pod', 'out.tmp'); | |
57 | my $expected = ''; | |
58 | while (<DATA>) { | |
59 | last if $_ eq "###\n"; | |
60 | $expected .= $_; | |
61 | } | |
62 | if ($output eq $expected) { | |
63 | print "ok $n\n"; | |
64 | } else { | |
65 | print "not ok $n\n"; | |
66 | print "Expected\n========\n$expected\nOutput\n======\n$output\n"; | |
67 | } | |
68 | $n++; | |
69 | } | |
70 | ||
71 | # Below the marker are bits of POD and corresponding expected output. This is | |
72 | # used to test specific features or problems with Pod::Text::Termcap. The | |
73 | # input and output are separated by lines containing only ###. | |
74 | ||
75 | __DATA__ | |
76 | ||
77 | ### | |
78 | =head1 WRAPPING | |
79 | ||
80 | B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>. | |
81 | ### | |
82 | \e[1mWRAPPING\e[m | |
83 | \e[1m\e[4mDo\e[m\e[m \e[4m\e[1mnot\e[m\e[m \e[1m\e[4minclude\e[m\e[m \e[1m\e[4mformatting codes when\e[m\e[m \e[1m\e[4mwrapping\e[m\e[m. | |
84 | ||
85 | ### |