diff options
author | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-01-22 17:19:17 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-01-22 17:19:17 +0100 |
commit | fe61459e95657c432074058bd8854fec03559335 (patch) | |
tree | a6a68c10689af759d17b71e16425dc8f519179c9 /cpan/podlators/t | |
parent | 47bd56ab669218f71586b01b08c680861542c90b (diff) | |
download | perl-fe61459e95657c432074058bd8854fec03559335.tar.gz |
Update to podlators 2.3.0
Diffstat (limited to 'cpan/podlators/t')
-rw-r--r-- | cpan/podlators/t/basic.t | 125 | ||||
-rw-r--r-- | cpan/podlators/t/color.t | 79 | ||||
-rwxr-xr-x | cpan/podlators/t/devise-date.t | 15 | ||||
-rw-r--r-- | cpan/podlators/t/filehandle.t | 47 | ||||
-rwxr-xr-x | cpan/podlators/t/man-heading.t | 90 | ||||
-rw-r--r-- | cpan/podlators/t/man-options.t | 46 | ||||
-rw-r--r-- | cpan/podlators/t/man-utf8.t | 60 | ||||
-rw-r--r-- | cpan/podlators/t/man.t | 72 | ||||
-rwxr-xr-x | cpan/podlators/t/overstrike.t | 103 | ||||
-rw-r--r-- | cpan/podlators/t/parselink.t | 50 | ||||
-rw-r--r-- | cpan/podlators/t/pod-parser.t | 52 | ||||
-rw-r--r-- | cpan/podlators/t/pod-spelling.t | 59 | ||||
-rw-r--r-- | cpan/podlators/t/pod.t | 17 | ||||
-rw-r--r-- | cpan/podlators/t/termcap.t | 65 | ||||
-rw-r--r-- | cpan/podlators/t/text-encoding.t | 52 | ||||
-rw-r--r-- | cpan/podlators/t/text-options.t | 40 | ||||
-rw-r--r-- | cpan/podlators/t/text-utf8.t | 49 | ||||
-rw-r--r-- | cpan/podlators/t/text.t | 39 |
18 files changed, 616 insertions, 444 deletions
diff --git a/cpan/podlators/t/basic.t b/cpan/podlators/t/basic.t index 603d108574..eb94ef22a3 100644 --- a/cpan/podlators/t/basic.t +++ b/cpan/podlators/t/basic.t @@ -2,7 +2,7 @@ # # basic.t -- Basic tests for podlators. # -# Copyright 2001, 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu> +# Copyright 2001, 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,22 +11,21 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..11\n"; } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::Man; -use Pod::Text; -use Pod::Text::Overstrike; -use Pod::Text::Termcap; +use Test::More tests => 15; + +BEGIN { + use_ok ('Pod::Man'); + use_ok ('Pod::Text'); + use_ok ('Pod::Text::Overstrike'); + use_ok ('Pod::Text::Termcap'); +} # Find the path to the test source files. This requires some fiddling when # these tests are run as part of Perl core. @@ -42,9 +41,6 @@ sub source_path { } } -$loaded = 1; -print "ok 1\n"; - # Hard-code a few values to try to get reproducible results. $ENV{COLUMNS} = 80; $ENV{TERM} = 'xterm'; @@ -59,69 +55,62 @@ my %translators = ('Pod::Man' => 'man', 'Pod::Text::Termcap' => 'cap'); # Set default options to match those of pod2man and pod2text. -%options = (sentence => 0); +our %options = (sentence => 0); -my $n = 2; -for (sort keys %translators) { - if ($_ eq 'Pod::Text::Color') { - eval { require Term::ANSIColor }; - if ($@) { - print "ok $n # skip\n"; - $n++; - print "ok $n # skip\n"; - $n++; - next; +for my $module (sort keys %translators) { + SKIP: { + if ($module eq 'Pod::Text::Color') { + eval { require Term::ANSIColor }; + skip 'Term::ANSIColor not found', 3 if $@; + require_ok ('Pod::Text::Color'); } - require Pod::Text::Color; - } - my $parser = $_->new (%options); - print (($parser && ref ($parser) eq $_) ? "ok $n\n" : "not ok $n\n"); - $n++; + my $parser = $module->new (%options); + isa_ok ($parser, $module, 'Parser object'); - # For Pod::Man, strip out the autogenerated header up to the .TH title - # line. That means that we don't check those things; oh well. The header - # changes with each version change or touch of the input file. - open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; - $parser->parse_from_file (source_path ('basic.pod'), \*OUT); - close OUT; - if ($_ eq 'Pod::Man') { - open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; - open (OUTPUT, "> out.$translators{$_}") - or die "Cannot create out.$translators{$_}: $!\n"; - local $_; - while (<TMP>) { last if /^\.nh/ } - print OUTPUT while <TMP>; - close OUTPUT; - close TMP; - unlink 'out.tmp'; - } else { - rename ('out.tmp', "out.$translators{$_}") - or die "Cannot rename out.tmp: $!\n"; - } - { - local $/; - open (MASTER, source_path ("basic.$translators{$_}")) - or die "Cannot open basic.$translators{$_}: $!\n"; - open (OUTPUT, "out.$translators{$_}") - or die "Cannot open out.$translators{$_}: $!\n"; - my $master = <MASTER>; - my $output = <OUTPUT>; - close MASTER; - close OUTPUT; + # For Pod::Man, strip out the autogenerated header up to the .TH title + # line. That means that we don't check those things; oh well. The + # header changes with each version change or touch of the input file. + open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; + $parser->parse_from_file (source_path ('basic.pod'), \*OUT); + close OUT; + if ($module eq 'Pod::Man') { + open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; + open (OUTPUT, "> out.$translators{$module}") + or die "Cannot create out.$translators{$module}: $!\n"; + local $_; + while (<TMP>) { last if /^\.nh/ } + print OUTPUT while <TMP>; + close OUTPUT; + close TMP; + 1 while unlink 'out.tmp'; + } else { + rename ('out.tmp', "out.$translators{$module}") + or die "Cannot rename out.tmp: $!\n"; + } + + # Slurp the output and expected output and compare them. + my ($master, $output); + { + local $/; + open (MASTER, source_path ("basic.$translators{$module}")) + or die "Cannot open basic.$translators{$module}: $!\n"; + open (OUTPUT, "out.$translators{$module}") + or die "Cannot open out.$translators{$module}: $!\n"; + $master = <MASTER>; + $output = <OUTPUT>; + close MASTER; + close OUTPUT; + } # OS/390 is EBCDIC, which uses a different character for ESC # apparently. Try to convert so that the test still works. - if ($^O eq 'os390' && $_ eq 'Pod::Text::Termcap') { + if ($^O eq 'os390' and $module eq 'Pod::Text::Termcap') { $output =~ tr/\033/\047/; } - - if ($master eq $output) { - print "ok $n\n"; - unlink "out.$translators{$_}"; + if (ok ($master eq $output, "$module output is correct")) { + 1 while unlink "out.$translators{$module}"; } else { - print "not ok $n\n"; - print "# Non-matching output left in out.$translators{$_}\n"; + diag ("Non-matching output left in out.$translators{$module}\n"); } } - $n++; } 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>>. [1m[33mDo[0m[0m [33m[1mnot[0m[0m [1m[33minclude[0m[0m [1m[33mformatting codes when[0m[0m [1m[33mwrapping[0m[0m. ### + +### +=head1 TAG WIDTH + +=over 10 + +=item 12345678 + +A + +=item B<12345678> + +B + +=item 1 + +C + +=item B<1> + +D + +=back +### +[1mTAG WIDTH[0m + 12345678 A + + [1m12345678[0m B + + 1 C + + [1m1[0m D + +### diff --git a/cpan/podlators/t/devise-date.t b/cpan/podlators/t/devise-date.t new file mode 100755 index 0000000000..3cce9f5b01 --- /dev/null +++ b/cpan/podlators/t/devise-date.t @@ -0,0 +1,15 @@ +#!/usr/bin/perl -w + +# In order for MakeMaker to build in the core, nothing can use +# Fcntl which includes POSIX. devise_date()'s use of strftime() +# was replaced. This tests that it's identical. + +use strict; + +use Test::More tests => 1; + +use Pod::Man; +use POSIX qw(strftime); + +my $parser = Pod::Man->new; +is $parser->devise_date, strftime("%Y-%m-%d", localtime); diff --git a/cpan/podlators/t/filehandle.t b/cpan/podlators/t/filehandle.t index a53884d50d..1ed0667b33 100644 --- a/cpan/podlators/t/filehandle.t +++ b/cpan/podlators/t/filehandle.t @@ -2,7 +2,7 @@ # # filehandle.t -- Test the parse_from_filehandle interface. # -# Copyright 2006 by Russ Allbery <rra@stanford.edu> +# Copyright 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,27 +11,24 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..3\n"; } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::Man; -use Pod::Text; +use Test::More tests => 6; -$loaded = 1; -print "ok 1\n"; +BEGIN { + use_ok ('Pod::Man'); + use_ok ('Pod::Text'); +} -my $man = Pod::Man->new or die "Cannot create parser\n"; -my $text = Pod::Text->new or die "Cannot create parser\n"; -my $n = 2; +my $man = Pod::Man->new; +isa_ok ($man, 'Pod::Man', 'Pod::Man parser object'); +my $text = Pod::Text->new; +isa_ok ($text, 'Pod::Text', 'Pod::Text parser object'); while (<DATA>) { next until $_ eq "###\n"; open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; @@ -40,6 +37,8 @@ while (<DATA>) { print TMP $_; } close TMP; + + # Test Pod::Man output. open (IN, '< tmp.pod') or die "Cannot open tmp.pod: $!\n"; open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; $man->parse_from_filehandle (\*IN, \*OUT); @@ -58,13 +57,9 @@ 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"; - } - $n++; + is ($output, $expected, 'Pod::Man output is correct'); + + # Test Pod::Text output. open (IN, '< tmp.pod') or die "Cannot open tmp.pod: $!\n"; open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; $text->parse_from_filehandle (\*IN, \*OUT); @@ -76,19 +71,13 @@ while (<DATA>) { $output = <OUT>; } close OUT; - unlink ('tmp.pod', 'out.tmp'); + 1 while unlink ('tmp.pod', 'out.tmp'); $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"; - } - $n++; + is ($output, $expected, 'Pod::Text output is correct'); } # Below the marker are bits of POD, corresponding expected nroff output, and diff --git a/cpan/podlators/t/man-heading.t b/cpan/podlators/t/man-heading.t new file mode 100755 index 0000000000..f7e470e3c0 --- /dev/null +++ b/cpan/podlators/t/man-heading.t @@ -0,0 +1,90 @@ +#!/usr/bin/perl -w +# +# man-options.t -- Additional tests for Pod::Man options. +# +# Copyright 2002, 2004, 2006, 2008, 2009 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. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } + unshift (@INC, '../blib/lib'); + $| = 1; +} + +use strict; + +use Test::More tests => 7; +BEGIN { use_ok ('Pod::Man') } + +my $n = 1; +while (<DATA>) { + my %options; + next until $_ eq "###\n"; + while (<DATA>) { + last if $_ eq "###\n"; + my ($option, $value) = split (' ', $_, 2); + chomp $value; + $options{$option} = $value; + } + open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; + print TMP "=head1 NAME\n\ntest - Test man page\n"; + close TMP; + my $parser = Pod::Man->new (%options); + isa_ok ($parser, 'Pod::Man', 'Parser object'); + open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; + $parser->parse_from_file ('tmp.pod', \*OUT); + close OUT; + open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; + my $heading; + while (<TMP>) { + if (/^\.TH/) { + $heading = $_; + last; + } + } + close TMP; + unlink ('tmp.pod', 'out.tmp'); + my $expected = ''; + while (<DATA>) { + last if $_ eq "###\n"; + $expected .= $_; + } + is ($heading, $expected, "Heading is correct for test $n"); + $n++; +} + +# Below the marker are sets of options and the corresponding expected .TH line +# from the man page. This is used to test specific features or problems with +# Pod::Man. The options and output are separated by lines containing only +# ###. + +__DATA__ + +### +date 2009-01-17 +release 1.0 +### +.TH TMP 1 "2009-01-17" "1.0" "User Contributed Perl Documentation" +### + +### +date 2009-01-17 +name TEST +section 8 +release 2.0-beta +### +.TH TEST 8 "2009-01-17" "2.0-beta" "User Contributed Perl Documentation" +### + +### +date 2009-01-17 +release 1.0 +center Testing Documentation +### +.TH TMP 1 "2009-01-17" "1.0" "Testing Documentation" +### diff --git a/cpan/podlators/t/man-options.t b/cpan/podlators/t/man-options.t index 04895d539c..0cc09fae2b 100644 --- a/cpan/podlators/t/man-options.t +++ b/cpan/podlators/t/man-options.t @@ -2,7 +2,7 @@ # # man-options.t -- Additional tests for Pod::Man options. # -# Copyright 2002, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu> +# Copyright 2002, 2004, 2006, 2008, 2009 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,19 +11,15 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..7\n"; } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::Man; +use Test::More tests => 10; +BEGIN { use_ok ('Pod::Man') } # Redirect stderr to a file. sub stderr_save { @@ -38,10 +34,7 @@ sub stderr_restore { close OLDERR; } -$loaded = 1; -print "ok 1\n"; - -my $n = 2; +my $n = 1; while (<DATA>) { my %options; next until $_ eq "###\n"; @@ -56,7 +49,8 @@ while (<DATA>) { print TMP $_; } close TMP; - my $parser = Pod::Man->new (%options) or die "Cannot create parser\n"; + my $parser = Pod::Man->new (%options); + isa_ok ($parser, 'Pod::Man', 'Parser object'); open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; stderr_save; $parser->parse_from_file ('tmp.pod', \*OUT); @@ -73,19 +67,13 @@ 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"; - } - $n++; + is ($output, $expected, "Output correct for test $n"); open (ERR, 'out.err') or die "Cannot open out.err: $!\n"; my $errors; { @@ -93,24 +81,20 @@ while (<DATA>) { $errors = <ERR>; } close ERR; - unlink ('out.err'); + 1 while unlink ('out.err'); $expected = ''; while (<DATA>) { last if $_ eq "###\n"; $expected .= $_; } - if ($errors eq $expected) { - print "ok $n\n"; - } else { - print "not ok $n\n"; - print "Expected errors:\n ${expected}Errors:\n $errors"; - } + is ($errors, $expected, "Errors are correct for test $n"); $n++; } -# Below the marker are bits of POD and corresponding expected text output. -# This is used to test specific features or problems with Pod::Man. The -# input and output are separated by lines containing only ###. +# Below the marker are bits of POD and corresponding expected text output and +# error output. This is used to test specific features or problems with +# Pod::Man. The options, input, output, and errors are separated by lines +# containing only ###. __DATA__ diff --git a/cpan/podlators/t/man-utf8.t b/cpan/podlators/t/man-utf8.t index 8b44d6b290..05a1505e20 100644 --- a/cpan/podlators/t/man-utf8.t +++ b/cpan/podlators/t/man-utf8.t @@ -2,7 +2,7 @@ # # man-options.t -- Additional tests for Pod::Man options. # -# Copyright 2002, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu> +# Copyright 2002, 2004, 2006, 2008, 2009 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,35 +11,34 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..5\n"; - - # UTF-8 support requires Perl 5.8 or later. - if ($] < 5.008) { - my $n; - for $n (1..5) { - print "ok $n # skip -- Perl 5.8 required for UTF-8 support\n"; - } - exit; - } } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::Man; +use Test::More; -$loaded = 1; -print "ok 1\n"; +# UTF-8 support requires Perl 5.8 or later. +BEGIN { + if ($] < 5.008) { + plan skip_all => 'Perl 5.8 required for UTF-8 support'; + } else { + plan tests => 7; + } +} +BEGIN { use_ok ('Pod::Man') } -my $n = 2; +# Force UTF-8 on all relevant file handles. Do this inside eval in case the +# encoding parameter doesn't work. eval { binmode (\*DATA, ':encoding(utf-8)') }; eval { binmode (\*STDOUT, ':encoding(utf-8)') }; +my $builder = Test::More->builder; +eval { binmode ($builder->output, ':encoding(utf-8)') }; +eval { binmode ($builder->failure_output, ':encoding(utf-8)') }; + +my $n = 1; while (<DATA>) { my %options; next until $_ eq "###\n"; @@ -56,7 +55,8 @@ while (<DATA>) { print TMP $_; } close TMP; - my $parser = Pod::Man->new (%options) or die "Cannot create parser\n"; + my $parser = Pod::Man->new (%options); + isa_ok ($parser, 'Pod::Man', 'Parser object'); open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; $parser->parse_from_file ('tmp.pod', \*OUT); close OUT; @@ -73,26 +73,18 @@ while (<DATA>) { $output = <TMP>; } close TMP; - unlink ('tmp.pod', 'out.tmp'); - if (($options{utf8} && !$accents) || (!$options{utf8} && $accents)) { - print "ok $n\n"; + 1 while unlink ('tmp.pod', 'out.tmp'); + if ($options{utf8}) { + ok (!$accents, "Saw no accent definitions for test $n"); } else { - print "not ok $n\n"; - print ($accents ? "Saw accents\n" : "Saw no accents\n"); - print ($options{utf8} ? "Wanted no accents\n" : "Wanted accents\n"); + ok ($accents, "Saw accent definitions for test $n"); } - $n++; 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++; } diff --git a/cpan/podlators/t/man.t b/cpan/podlators/t/man.t index 419cce3ee6..ea5a636ab5 100644 --- a/cpan/podlators/t/man.t +++ b/cpan/podlators/t/man.t @@ -2,7 +2,7 @@ # # man.t -- Additional specialized tests for Pod::Man. # -# Copyright 2002, 2003, 2004, 2006, 2007, 2008 +# Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009 # Russ Allbery <rra@stanford.edu> # # This program is free software; you may redistribute it and/or modify it @@ -12,28 +12,22 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..25\n"; } -END { - print "not ok 1\n" unless $loaded; -} - -use Pod::Man; +use strict; -$loaded = 1; -print "ok 1\n"; +use Test::More tests => 30; +BEGIN { use_ok ('Pod::Man') } # Test whether we can use binmode to set encoding. my $have_encoding = (eval { require PerlIO::encoding; 1 } and not $@); -my $parser = Pod::Man->new or die "Cannot create parser\n"; -my $n = 2; +my $parser = Pod::Man->new; +isa_ok ($parser, 'Pod::Man', 'Parser object'); +my $n = 1; while (<DATA>) { next until $_ eq "###\n"; open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; @@ -59,18 +53,13 @@ while (<DATA>) { $output = <OUT>; } close OUT; - 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++; } @@ -83,14 +72,14 @@ __DATA__ ### =head1 NAME -gcc - GNU project C and C++ compiler +gcc - GNU project C<C> and C++ compiler =head1 C++ NOTES Other mentions of C++. ### .SH "NAME" -gcc \- GNU project C and C++ compiler +gcc \- GNU project "C" and C++ compiler .SH "\*(C+ NOTES" .IX Header " NOTES" Other mentions of \*(C+. @@ -482,3 +471,42 @@ Some raw nroff. .PP More text. ### + +### +=head1 NAME + +test - C<test> +### +.SH "NAME" +test \- "test" +### + +### +=head1 INDEX + +Index entry matching a whitespace escape.X<\n> +### +.SH "INDEX" +.IX Header "INDEX" +Index entry matching a whitespace escape. +.IX Xref "\\n" +### + +### +=head1 LINK TO URL + +This is a L<link|http://www.example.com/> to a URL. +### +.SH "LINK TO URL" +.IX Header "LINK TO URL" +This is a link <http://www.example.com/> to a \s-1URL\s0. +### + +### +=head1 NAME + +test - B<test> I<italics> F<file> +### +.SH "NAME" +test \- test italics file +### diff --git a/cpan/podlators/t/overstrike.t b/cpan/podlators/t/overstrike.t new file mode 100755 index 0000000000..bbfa0db9fb --- /dev/null +++ b/cpan/podlators/t/overstrike.t @@ -0,0 +1,103 @@ +#!/usr/bin/perl -w +# +# overstrike.t -- Additional specialized tests for Pod::Text::Overstrike. +# +# 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. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } + unshift (@INC, '../blib/lib'); + $| = 1; +} + +use strict; + +use Test::More tests => 4; +BEGIN { use_ok ('Pod::Text::Overstrike') } + +my $parser = Pod::Text::Overstrike->new; +isa_ok ($parser, 'Pod::Text::Overstrike', 'Parser module'); +my $n = 1; +while (<DATA>) { + next until $_ eq "###\n"; + open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; + while (<DATA>) { + last if $_ eq "###\n"; + print TMP $_; + } + close TMP; + open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; + $parser->parse_from_file ('tmp.pod', \*OUT); + close OUT; + open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; + my $output; + { + local $/; + $output = <TMP>; + } + close TMP; + 1 while unlink ('tmp.pod', 'out.tmp'); + my $expected = ''; + while (<DATA>) { + last if $_ eq "###\n"; + $expected .= $_; + } + 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 ###. + +__DATA__ + +### +=head1 WRAPPING + +B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>. +### +WWRRAAPPPPIINNGG + DDoo _n_o_t iinncclluuddee ffoorrmmaattttiinngg ccooddeess wwhheenn wwrraappppiinngg. + +### + +### +=head1 TAG WIDTH + +=over 10 + +=item 12345678 + +A + +=item B<12345678> + +B + +=item 1 + +C + +=item B<1> + +D + +=back +### +TTAAGG WWIIDDTTHH + 12345678 A + + 1122334455667788 B + + 1 C + + 11 D + +### diff --git a/cpan/podlators/t/parselink.t b/cpan/podlators/t/parselink.t index c5c2bb660b..828b2ec8e1 100644 --- a/cpan/podlators/t/parselink.t +++ b/cpan/podlators/t/parselink.t @@ -2,17 +2,14 @@ # # parselink.t -- Tests for Pod::ParseLink. # -# Copyright 2001 by Russ Allbery <rra@stanford.edu> +# Copyright 2001, 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. # The format of each entry in this array is the L<> text followed by the -# five-element parse returned by parselink. When adding a new test, also -# increment the test count in the BEGIN block below. We don't use any of the -# fancy test modules intentionally for backward compatibility to older -# versions of Perl. -@TESTS = ( +# five-element parse returned by parselink. +our @TESTS = ( [ 'foo', undef, 'foo', 'foo', undef, 'pod' ], @@ -87,46 +84,37 @@ [ 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'news:yld72axzc8.fsf@windlord.stanford.edu', - 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'url' ] + 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'url' ], + + [ 'link|http://www.perl.org/', + 'link', 'link', 'http://www.perl.org/', undef, 'url' ], + + [ '0|http://www.perl.org/', + '0', '0', 'http://www.perl.org/', undef, 'url' ], + + [ '0|Pod::Parser', + '0', '0', 'Pod::Parser', undef, 'pod' ], ); BEGIN { chdir 't' if -d 't'; unshift (@INC, '../blib/lib'); $| = 1; - print "1..25\n"; } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::ParseLink; -$loaded = 1; -print "ok 1\n"; +use Test::More tests => 28; +BEGIN { use_ok ('Pod::ParseLink') } # Used for reporting test failures. my @names = qw(text inferred name section type); -my $n = 2; for (@TESTS) { my @expected = @$_; my $link = shift @expected; my @results = parselink ($link); - my $okay = 1; - for (0..4) { - # Make sure to check undef explicitly; we don't want undef to match - # the empty string because they're semantically different. - unless ((!defined ($results[$_]) && !defined ($expected[$_])) - || (defined ($results[$_]) && defined ($expected[$_]) - && $results[$_] eq $expected[$_])) { - print "not ok $n\n" if $okay; - print "# Incorrect $names[$_]:\n"; - print "# expected: $expected[$_]\n"; - print "# seen: $results[$_]\n"; - $okay = 0; - } - } - print "ok $n\n" if $okay; - $n++; + my $pretty = $link; + $pretty =~ s/\n/\\n/g; + is_deeply (\@results, \@expected, $pretty); } diff --git a/cpan/podlators/t/pod-parser.t b/cpan/podlators/t/pod-parser.t index 318a76bc15..ae2ef01676 100644 --- a/cpan/podlators/t/pod-parser.t +++ b/cpan/podlators/t/pod-parser.t @@ -2,7 +2,7 @@ # # pod-parser.t -- Tests for backward compatibility with Pod::Parser. # -# Copyright 2006, 2008 by Russ Allbery <rra@stanford.edu> +# Copyright 2006, 2008, 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,28 +11,21 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..4\n"; } -my $loaded; - -END { - print "not ok 1\n" unless $loaded; -} - -use Pod::Man; -use Pod::Text; use strict; -$loaded = 1; -print "ok 1\n"; +use Test::More tests => 7; +BEGIN { + use_ok ('Pod::Man'); + use_ok ('Pod::Text'); +} -my $parser = Pod::Man->new or die "Cannot create parser\n"; +my $parser = Pod::Man->new; +isa_ok ($parser, 'Pod::Man', 'Pod::Man parser object'); open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; print TMP "Some random B<text>.\n"; close TMP; @@ -47,15 +40,10 @@ my $output; $output = <OUT>; } close OUT; -if ($output eq "Some random \\fBtext\\fR.\n") { - print "ok 2\n"; -} else { - print "not ok 2\n"; - print "Expected\n========\nSome random \\fBtext\\fR.\n\n"; - print "Output\n======\n$output\n"; -} +is ($output, "Some random \\fBtext\\fR.\n", 'Pod::Man -cutting output'); -$parser = Pod::Text->new or die "Cannot create parser\n"; +$parser = Pod::Text->new; +isa_ok ($parser, 'Pod::Text', 'Pod::Text parser object'); open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; $parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT); close OUT; @@ -65,13 +53,7 @@ open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n"; $output = <OUT>; } close OUT; -if ($output eq " Some random text.\n\n") { - print "ok 3\n"; -} else { - print "not ok 3\n"; - print "Expected\n========\n Some random text.\n\n\n"; - print "Output\n======\n$output\n"; -} +is ($output, " Some random text.\n\n", 'Pod::Text -cutting output'); # Test the pod2text function, particularly with only one argument. open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; @@ -90,13 +72,7 @@ open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n"; $output = <OUT>; } close OUT; -if ($output eq " Some random text.\n\n") { - print "ok 4\n"; -} else { - print "not ok 4\n"; - print "Expected\n========\n Some random text.\n\n\n"; - print "Output\n======\n$output\n"; -} +is ($output, " Some random text.\n\n", 'Pod::Text pod2text function'); -unlink ('tmp.pod', 'out.tmp'); +1 while unlink ('tmp.pod', 'out.tmp'); exit 0; diff --git a/cpan/podlators/t/pod-spelling.t b/cpan/podlators/t/pod-spelling.t index 41c902782e..d3ab858f9e 100644 --- a/cpan/podlators/t/pod-spelling.t +++ b/cpan/podlators/t/pod-spelling.t @@ -1,28 +1,32 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # -# t/pod-spelling.t -- Test POD spelling. +# Check for spelling errors in POD documentation # -# Copyright 2008 Russ Allbery <rra@stanford.edu> +# Checks all POD files in the tree for spelling problems using Pod::Spell and +# either aspell or ispell. aspell is preferred. This test is disabled unless +# RRA_MAINTAINER_TESTS is set, since spelling dictionaries vary too much +# between environments. +# +# Copyright 2008, 2009 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. -# Called to skip all tests with a reason. -sub skip_all { - print "1..0 # Skipped: @_\n"; - exit; -} +use strict; +use Test::More; -# Skip all spelling tests unless flagged to run maintainer tests. -skip_all "Spelling tests only run for maintainer" +# Skip all spelling tests unless the maintainer environment variable is set. +plan skip_all => 'Spelling tests only run for maintainer' unless $ENV{RRA_MAINTAINER_TESTS}; -# Make sure we have prerequisites. hunspell is currently not supported due to -# lack of support for contractions. +# Load required Perl modules. eval 'use Test::Pod 1.00'; -skip_all "Test::Pod 1.00 required for testing POD" if $@; +plan skip_all => 'Test::Pod 1.00 required for testing POD' if $@; eval 'use Pod::Spell'; -skip_all "Pod::Spell required to test POD spelling" if $@; +plan skip_all => 'Pod::Spell required to test POD spelling' if $@; + +# Locate a spell-checker. hunspell is not currently supported due to its lack +# of support for contractions (at least in the version in Debian). my @spell; my %options = (aspell => [ qw(-d en_US --home-dir=./ list) ], ispell => [ qw(-d american -l -p /dev/null) ]); @@ -34,21 +38,22 @@ SEARCH: for my $program (qw/aspell ispell/) { last SEARCH if @spell; } } -skip_all "aspell or ispell required to test POD spelling" unless @spell; +plan skip_all => 'aspell or ispell required to test POD spelling' + unless @spell; -# Run the test, one for each POD file. +# Prerequisites are satisfied, so we're going to do some testing. Figure out +# what POD files we have and from that develop our plan. $| = 1; my @pod = all_pod_files (); -my $count = scalar @pod; -print "1..$count\n"; -my $n = 1; +plan tests => scalar @pod; + +# Finally, do the checks. for my $pod (@pod) { my $child = open (CHILD, '-|'); if (not defined $child) { die "Cannot fork: $!\n"; } elsif ($child == 0) { - my $pid = open (SPELL, '|-', @spell) - or die "Cannot run @spell: $!\n"; + my $pid = open (SPELL, '|-', @spell) or die "Cannot run @spell: $!\n"; open (POD, '<', $pod) or die "Cannot open $pod: $!\n"; my $parser = Pod::Spell->new; $parser->parse_from_filehandle (\*POD, \*SPELL); @@ -58,19 +63,13 @@ for my $pod (@pod) { } else { my @words = <CHILD>; close CHILD; - if ($? != 0) { - print "ok $n # skip - @spell failed: $?\n"; - } elsif (@words) { + SKIP: { + skip "@spell failed for $pod", 1 unless $? == 0; for (@words) { s/^\s+//; s/\s+$//; } - print "not ok $n\n"; - print " - Misspelled words found in $pod\n"; - print " @words\n"; - } else { - print "ok $n\n"; + is ("@words", '', $pod); } - $n++; } } diff --git a/cpan/podlators/t/pod.t b/cpan/podlators/t/pod.t index ecb37a642c..e570e18bb4 100644 --- a/cpan/podlators/t/pod.t +++ b/cpan/podlators/t/pod.t @@ -1,11 +1,14 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # -# t/pod.t -- Test POD formatting. +# Test POD formatting. +# +# Copyright 2009 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. +use strict; +use Test::More; eval 'use Test::Pod 1.00'; -if ($@) { - print "1..1\n"; - print "ok 1 # skip - Test::Pod 1.00 required for testing POD\n"; - exit; -} +plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok (); diff --git a/cpan/podlators/t/termcap.t b/cpan/podlators/t/termcap.t index 5ec98288f6..c75cb44bb4 100644 --- a/cpan/podlators/t/termcap.t +++ b/cpan/podlators/t/termcap.t @@ -2,7 +2,7 @@ # # termcap.t -- Additional specialized tests for Pod::Text::Termcap. # -# 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,30 +11,24 @@ 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 tests => 4; +BEGIN { use_ok ('Pod::Text::Termcap') } # Hard-code a few values to try to get reproducible results. $ENV{COLUMNS} = 80; $ENV{TERM} = 'xterm'; $ENV{TERMCAP} = 'xterm:co=80:do=^J:md=\E[1m:us=\E[4m:me=\E[m'; -use Pod::Text::Termcap; - -$loaded = 1; -print "ok 1\n"; - -my $parser = Pod::Text::Termcap->new or die "Cannot create parser\n"; -my $n = 2; +my $parser = Pod::Text::Termcap->new; +isa_ok ($parser, 'Pod::Text::Termcap', 'Parser module'); +my $n = 1; while (<DATA>) { next until $_ eq "###\n"; open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; @@ -53,18 +47,13 @@ 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++; } @@ -83,3 +72,37 @@ B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>. [1m[4mDo[m[m [4m[1mnot[m[m [1m[4minclude[m[m [1m[4mformatting codes when[m[m [1m[4mwrapping[m[m. ### + +### +=head1 TAG WIDTH + +=over 10 + +=item 12345678 + +A + +=item B<12345678> + +B + +=item 1 + +C + +=item B<1> + +D + +=back +### +[1mTAG WIDTH[m + 12345678 A + + [1m12345678[m B + + 1 C + + [1m1[m D + +### diff --git a/cpan/podlators/t/text-encoding.t b/cpan/podlators/t/text-encoding.t index c803cff1f9..14181e80dd 100644 --- a/cpan/podlators/t/text-encoding.t +++ b/cpan/podlators/t/text-encoding.t @@ -2,7 +2,8 @@ # # text-encoding.t -- Test Pod::Text with various weird encoding combinations. # -# Copyright 2002, 2004, 2006, 2007, 2008 by Russ Allbery <rra@stanford.edu> +# Copyright 2002, 2004, 2006, 2007, 2008, 2009 +# 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,40 +12,38 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..4\n"; - - # PerlIO encoding support requires Perl 5.8 or later. - if ($] < 5.008) { - my $n; - for $n (1..4) { - print "ok $n # skip -- Perl 5.8 required for UTF-8 support\n"; - } - exit; - } } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::Text; +use Test::More; -$loaded = 1; -print "ok 1\n"; +# UTF-8 support requires Perl 5.8 or later. +BEGIN { + if ($] < 5.008) { + plan skip_all => 'Perl 5.8 required for encoding support'; + } else { + plan tests => 7; + } +} +BEGIN { use_ok ('Pod::Text') } -my $n = 2; eval { binmode (\*DATA, ':raw') }; eval { binmode (\*STDOUT, ':raw') }; +my $builder = Test::More->builder; +eval { binmode ($builder->output, ':raw') }; +eval { binmode ($builder->failure_output, ':raw') }; + +my $n = 1; while (<DATA>) { my %opts; - $opts{utf8} = 1 if $n == 4; - my $parser = Pod::Text->new (%opts) or die "Cannot create parser\n"; + $opts{utf8} = 1 if $n == 3; next until $_ eq "###\n"; + my $parser = Pod::Text->new (%opts); + isa_ok ($parser, 'Pod::Text', 'Parser object'); open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; eval { binmode (\*TMP, ':raw') }; while (<DATA>) { @@ -64,18 +63,13 @@ 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++; } diff --git a/cpan/podlators/t/text-options.t b/cpan/podlators/t/text-options.t index 8a115d83a5..7b70980785 100644 --- a/cpan/podlators/t/text-options.t +++ b/cpan/podlators/t/text-options.t @@ -2,7 +2,7 @@ # # text-options.t -- Additional tests for Pod::Text options. # -# Copyright 2002, 2004, 2006, 2008 by Russ Allbery <rra@stanford.edu> +# Copyright 2002, 2004, 2006, 2008, 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,19 +11,15 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..13\n"; } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::Text; +use Test::More tests => 19; +BEGIN { use_ok ('Pod::Text') } # Redirect stderr to a file. sub stderr_save { @@ -38,10 +34,7 @@ sub stderr_restore { close OLDERR; } -$loaded = 1; -print "ok 1\n"; - -my $n = 2; +my $n = 1; while (<DATA>) { my %options; next until $_ eq "###\n"; @@ -56,7 +49,8 @@ while (<DATA>) { print TMP $_; } close TMP; - my $parser = Pod::Text->new (%options) or die "Cannot create parser\n"; + my $parser = Pod::Text->new (%options); + isa_ok ($parser, 'Pod::Text', 'Parser object'); open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; stderr_save; $parser->parse_from_file ('tmp.pod', \*OUT); @@ -75,13 +69,7 @@ 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"; - } - $n++; + is ($output, $expected, "Ouput correct for test $n"); open (ERR, 'out.err') or die "Cannot open out.err: $!\n"; my $errors; { @@ -89,24 +77,20 @@ while (<DATA>) { $errors = <ERR>; } close ERR; - unlink ('out.err'); + 1 while unlink ('out.err'); $expected = ''; while (<DATA>) { last if $_ eq "###\n"; $expected .= $_; } - if ($errors eq $expected) { - print "ok $n\n"; - } else { - print "not ok $n\n"; - print "Expected errors:\n ${expected}Errors:\n $errors"; - } + is ($errors, $expected, "Errors correct for test $n"); $n++; } # Below the marker are bits of POD and corresponding expected text output. # This is used to test specific features or problems with Pod::Text. The -# input and output are separated by lines containing only ###. +# options, input, output, and errors are separated by lines containing only +# ###. __DATA__ diff --git a/cpan/podlators/t/text-utf8.t b/cpan/podlators/t/text-utf8.t index 806947827e..4874de5021 100644 --- a/cpan/podlators/t/text-utf8.t +++ b/cpan/podlators/t/text-utf8.t @@ -2,7 +2,8 @@ # # text-utf8.t -- Test Pod::Text with UTF-8 input. # -# Copyright 2002, 2004, 2006, 2007, 2008 by Russ Allbery <rra@stanford.edu> +# Copyright 2002, 2004, 2006, 2007, 2008, 2009 +# 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,36 +12,33 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..3\n"; - - # UTF-8 support requires Perl 5.8 or later. - if ($] < 5.008) { - my $n; - for $n (1..3) { - print "ok $n # skip -- Perl 5.8 required for UTF-8 support\n"; - } - exit; - } } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::Text; +use Test::More; -$loaded = 1; -print "ok 1\n"; +# UTF-8 support requires Perl 5.8 or later. +BEGIN { + if ($] < 5.008) { + plan skip_all => 'Perl 5.8 required for UTF-8 support'; + } else { + plan tests => 4; + } +} +BEGIN { use_ok ('Pod::Text') } -my $parser = Pod::Text->new or die "Cannot create parser\n"; -my $n = 2; +my $parser = Pod::Text->new; +isa_ok ($parser, 'Pod::Text', 'Parser object'); +my $n = 1; eval { binmode (\*DATA, ':encoding(utf-8)') }; eval { binmode (\*STDOUT, ':encoding(utf-8)') }; +my $builder = Test::More->builder; +eval { binmode ($builder->output, ':encoding(utf-8)') }; +eval { binmode ($builder->failure_output, ':encoding(utf-8)') }; while (<DATA>) { next until $_ eq "###\n"; open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; @@ -62,18 +60,13 @@ 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++; } diff --git a/cpan/podlators/t/text.t b/cpan/podlators/t/text.t index c96acba63d..5b7f4384f7 100644 --- a/cpan/podlators/t/text.t +++ b/cpan/podlators/t/text.t @@ -11,26 +11,20 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; - } else { - unshift (@INC, '../blib/lib'); } unshift (@INC, '../blib/lib'); $| = 1; - print "1..6\n"; } -END { - print "not ok 1\n" unless $loaded; -} +use strict; -use Pod::Text; use Pod::Simple; +use Test::More tests => 8; +BEGIN { use_ok ('Pod::Text') } -$loaded = 1; -print "ok 1\n"; - -my $parser = Pod::Text->new or die "Cannot create parser\n"; -my $n = 2; +my $parser = Pod::Text->new; +isa_ok ($parser, 'Pod::Text', 'Parser object'); +my $n = 1; while (<DATA>) { next until $_ eq "###\n"; open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; @@ -49,20 +43,13 @@ 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"; - } elsif ($n == 4 && $Pod::Simple::VERSION < 3.06) { - print "ok $n # skip Pod::Simple S<> parsing bug\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++; } @@ -145,3 +132,13 @@ text line3 ### + +### +=head1 LINK TO URL + +This is a L<link|http://www.example.com/> to a URL. +### +LINK TO URL + This is a link <http://www.example.com/> to a URL. + +### |