Commit | Line | Data |
b7ae008f |
1 | #!/usr/bin/perl -w |
e2a52b10 |
2 | # $Id: color.t,v 1.3 2006-01-28 22:31:50 eagle Exp $ |
b7ae008f |
3 | # |
4 | # color.t -- Additional specialized tests for Pod::Text::Color. |
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 | eval { require Term::ANSIColor }; |
28 | if ($@) { |
29 | for (1..2) { |
30 | print "ok $_ # skip\n"; |
31 | } |
32 | $loaded = 1; |
33 | exit; |
34 | } |
35 | require Pod::Text::Color; |
36 | |
37 | $loaded = 1; |
38 | print "ok 1\n"; |
39 | |
8f202758 |
40 | my $parser = Pod::Text::Color->new or die "Cannot create parser\n"; |
b7ae008f |
41 | my $n = 2; |
42 | while (<DATA>) { |
43 | next until $_ eq "###\n"; |
44 | open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; |
45 | while (<DATA>) { |
46 | last if $_ eq "###\n"; |
47 | print TMP $_; |
48 | } |
49 | close TMP; |
e2a52b10 |
50 | open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; |
51 | $parser->parse_from_file ('tmp.pod', \*OUT); |
52 | close OUT; |
b7ae008f |
53 | open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; |
54 | my $output; |
55 | { |
56 | local $/; |
57 | $output = <TMP>; |
58 | } |
59 | close TMP; |
60 | unlink ('tmp.pod', 'out.tmp'); |
61 | my $expected = ''; |
62 | while (<DATA>) { |
63 | last if $_ eq "###\n"; |
64 | $expected .= $_; |
65 | } |
66 | if ($output eq $expected) { |
67 | print "ok $n\n"; |
68 | } else { |
69 | print "not ok $n\n"; |
70 | print "Expected\n========\n$expected\nOutput\n======\n$output\n"; |
71 | } |
72 | $n++; |
73 | } |
74 | |
75 | # Below the marker are bits of POD and corresponding expected output. This is |
76 | # used to test specific features or problems with Pod::Text::Termcap. The |
77 | # input and output are separated by lines containing only ###. |
78 | |
79 | __DATA__ |
80 | |
81 | ### |
82 | =head1 WRAPPING |
83 | |
84 | B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>. |
85 | ### |
86 | \e[1mWRAPPING\e[0m |
87 | \e[1m\e[33mDo\e[0m\e[0m \e[33m\e[1mnot\e[0m\e[0m \e[1m\e[33minclude\e[0m\e[0m \e[1m\e[33mformatting codes when\e[0m\e[0m \e[1m\e[33mwrapping\e[0m\e[0m. |
88 | |
89 | ### |