3 # color.t -- Additional specialized tests for Pod::Text::Color.
5 # Copyright 2002, 2004, 2006, 2009 by Russ Allbery <rra@stanford.edu>
7 # This program is free software; you may redistribute it and/or modify it
8 # under the same terms as Perl itself.
12 if ($ENV{PERL_CORE}) {
15 unshift (@INC, '../blib/lib');
23 # Skip this test if Term::ANSIColor isn't available.
24 eval { require Term::ANSIColor };
26 plan skip_all => 'Term::ANSIColor required for Pod::Text::Color';
30 require_ok ('Pod::Text::Color');
32 # Load tests from the data section below, write the POD to a temporary file,
33 # convert it, and compare to the expected output.
34 my $parser = Pod::Text::Color->new;
35 isa_ok ($parser, 'Pod::Text::Color', 'Parser object');
38 next until $_ eq "###\n";
39 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
41 last if $_ eq "###\n";
45 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
46 $parser->parse_from_file ('tmp.pod', \*OUT);
48 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
55 1 while unlink ('tmp.pod', 'out.tmp');
58 last if $_ eq "###\n";
61 is ($output, $expected, "Output correct for test $n");
65 # Below the marker are bits of POD and corresponding expected output. This is
66 # used to test specific features or problems with Pod::Text::Color. The input
67 # and output are separated by lines containing only ###.
74 B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>.
77 \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.