summaryrefslogtreecommitdiff
path: root/cpan/podlators/t/color.t
diff options
context:
space:
mode:
Diffstat (limited to 'cpan/podlators/t/color.t')
-rw-r--r--cpan/podlators/t/color.t79
1 files changed, 52 insertions, 27 deletions
diff --git a/cpan/podlators/t/color.t b/cpan/podlators/t/color.t
index 2f1668f88e..f6be17b7cd 100644
--- a/cpan/podlators/t/color.t
+++ b/cpan/podlators/t/color.t
@@ -2,7 +2,7 @@
#
# color.t -- Additional specialized tests for Pod::Text::Color.
#
-# Copyright 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2004, 2006, 2009 by Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.
@@ -11,33 +11,29 @@ BEGIN {
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..2\n";
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
+
+use Test::More;
+# Skip this test if Term::ANSIColor isn't available.
eval { require Term::ANSIColor };
if ($@) {
- for (1..2) {
- print "ok $_ # skip\n";
- }
- $loaded = 1;
- exit;
+ plan skip_all => 'Term::ANSIColor required for Pod::Text::Color';
+} else {
+ plan tests => 4;
}
-require Pod::Text::Color;
+require_ok ('Pod::Text::Color');
-$loaded = 1;
-print "ok 1\n";
-
-my $parser = Pod::Text::Color->new or die "Cannot create parser\n";
-my $n = 2;
+# Load tests from the data section below, write the POD to a temporary file,
+# convert it, and compare to the expected output.
+my $parser = Pod::Text::Color->new;
+isa_ok ($parser, 'Pod::Text::Color', 'Parser object');
+my $n = 1;
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
@@ -56,24 +52,19 @@ while (<DATA>) {
$output = <TMP>;
}
close TMP;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while unlink ('tmp.pod', 'out.tmp');
my $expected = '';
while (<DATA>) {
last if $_ eq "###\n";
$expected .= $_;
}
- if ($output eq $expected) {
- print "ok $n\n";
- } else {
- print "not ok $n\n";
- print "Expected\n========\n$expected\nOutput\n======\n$output\n";
- }
+ is ($output, $expected, "Output correct for test $n");
$n++;
}
# Below the marker are bits of POD and corresponding expected output. This is
-# used to test specific features or problems with Pod::Text::Termcap. The
-# input and output are separated by lines containing only ###.
+# used to test specific features or problems with Pod::Text::Color. The input
+# and output are separated by lines containing only ###.
__DATA__
@@ -86,3 +77,37 @@ B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>.
Do not include formatting codes when wrapping.
###
+
+###
+=head1 TAG WIDTH
+
+=over 10
+
+=item 12345678
+
+A
+
+=item B<12345678>
+
+B
+
+=item 1
+
+C
+
+=item B<1>
+
+D
+
+=back
+###
+TAG WIDTH
+ 12345678 A
+
+ 12345678 B
+
+ 1 C
+
+ 1 D
+
+###