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