Re: [PATCH] Make the 'sort' pragma lexically scoped
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / color.t
CommitLineData
b7ae008f 1#!/usr/bin/perl -w
2# $Id: color.t,v 1.1 2004/12/31 21:50:05 eagle Exp $
3#
4# color.t -- Additional specialized tests for Pod::Text::Color.
5#
6# Copyright 2002, 2004 by Russ Allbery <rra@stanford.edu>
7#
8# This program is free software; you may redistribute it and/or modify it
9# under the same terms as Perl itself.
10
11BEGIN {
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
23END {
24 print "not ok 1\n" unless $loaded;
25}
26
27eval { require Term::ANSIColor };
28if ($@) {
29 for (1..2) {
30 print "ok $_ # skip\n";
31 }
32 $loaded = 1;
33 exit;
34}
35require Pod::Text::Color;
36
37$loaded = 1;
38print "ok 1\n";
39
40my $n = 2;
41while (<DATA>) {
42 next until $_ eq "###\n";
43 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
44 while (<DATA>) {
45 last if $_ eq "###\n";
46 print TMP $_;
47 }
48 close TMP;
49 my $parser = Pod::Text::Color->new or die "Cannot create parser\n";
50 $parser->parse_from_file ('tmp.pod', 'out.tmp');
51 undef $parser;
52 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
53 my $output;
54 {
55 local $/;
56 $output = <TMP>;
57 }
58 close TMP;
59 unlink ('tmp.pod', 'out.tmp');
60 my $expected = '';
61 while (<DATA>) {
62 last if $_ eq "###\n";
63 $expected .= $_;
64 }
65 if ($output eq $expected) {
66 print "ok $n\n";
67 } else {
68 print "not ok $n\n";
69 print "Expected\n========\n$expected\nOutput\n======\n$output\n";
70 }
71 $n++;
72}
73
74# Below the marker are bits of POD and corresponding expected output. This is
75# used to test specific features or problems with Pod::Text::Termcap. The
76# input and output are separated by lines containing only ###.
77
78__DATA__
79
80###
81=head1 WRAPPING
82
83B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>.
84###
85\e[1mWRAPPING\e[0m
86 \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.
87
88###