diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2020-01-07 11:58:07 +0000 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2020-01-07 11:59:41 +0000 |
commit | 28997a26dcd9f1910cb1ef3b4c567e7e48f782b6 (patch) | |
tree | 53abf354824e25a97871f9e1265dd86d38d27493 /cpan | |
parent | 22ce58f7dc394e5929f9642af1194e0559dc4452 (diff) | |
download | perl-28997a26dcd9f1910cb1ef3b4c567e7e48f782b6.tar.gz |
Update podlators to CPAN version 4.14
[DELTA]
podlators 4.14 (2020-01-04)
Document that parse_lines and parse_string_document expect raw bytes,
not decoded characters.
Fix the test suite use of parse_string_document to pass in raw bytes
rather than decoded characters, which will hopefully fix test failures
with versions of Pod::Simple older than 3.22 and is a more correct
test of encoding handling.
Diffstat (limited to 'cpan')
22 files changed, 427 insertions, 422 deletions
diff --git a/cpan/podlators/lib/Pod/Man.pm b/cpan/podlators/lib/Pod/Man.pm index 7e6563d930..d7c029357a 100644 --- a/cpan/podlators/lib/Pod/Man.pm +++ b/cpan/podlators/lib/Pod/Man.pm @@ -34,7 +34,7 @@ BEGIN { @ISA = qw(Pod::Simple); -$VERSION = '4.13'; +$VERSION = '4.14'; # Set the debugging level. If someone has inserted a debug function into this # class already, use that. Otherwise, use any Pod::Simple debug function @@ -1878,7 +1878,9 @@ being the file to write the formatted output to. You can also call parse_lines() to parse an array of lines or parse_string_document() to parse a document already in memory. As with parse_file(), parse_lines() and parse_string_document() default to sending -their output to C<STDOUT> unless changed with the output_fh() method. +their output to C<STDOUT> unless changed with the output_fh() method. Be +aware that parse_lines() and parse_string_document() both expect raw bytes, +not decoded characters. To put the output from any parse method into a string instead of a file handle, call the output_string() method instead of output_fh(). diff --git a/cpan/podlators/lib/Pod/ParseLink.pm b/cpan/podlators/lib/Pod/ParseLink.pm index f910280862..273c95847a 100644 --- a/cpan/podlators/lib/Pod/ParseLink.pm +++ b/cpan/podlators/lib/Pod/ParseLink.pm @@ -23,7 +23,7 @@ use Exporter; @ISA = qw(Exporter); @EXPORT = qw(parselink); -$VERSION = '4.13'; +$VERSION = '4.14'; ############################################################################## # Implementation diff --git a/cpan/podlators/lib/Pod/Text.pm b/cpan/podlators/lib/Pod/Text.pm index 9ffcf74ebb..56e6e78a86 100644 --- a/cpan/podlators/lib/Pod/Text.pm +++ b/cpan/podlators/lib/Pod/Text.pm @@ -30,7 +30,7 @@ use Pod::Simple (); # We have to export pod2text for backward compatibility. @EXPORT = qw(pod2text); -$VERSION = '4.13'; +$VERSION = '4.14'; # Ensure that $Pod::Simple::nbsp and $Pod::Simple::shy are available. Code # taken from Pod::Simple 3.32, but was only added in 3.30. @@ -912,7 +912,9 @@ being the file to write the formatted output to. You can also call parse_lines() to parse an array of lines or parse_string_document() to parse a document already in memory. As with parse_file(), parse_lines() and parse_string_document() default to sending -their output to C<STDOUT> unless changed with the output_fh() method. +their output to C<STDOUT> unless changed with the output_fh() method. Be +aware that parse_lines() and parse_string_document() both expect raw bytes, +not decoded characters. To put the output from any parse method into a string instead of a file handle, call the output_string() method instead of output_fh(). diff --git a/cpan/podlators/lib/Pod/Text/Color.pm b/cpan/podlators/lib/Pod/Text/Color.pm index 09430d3d7f..5d47c5ecb3 100644 --- a/cpan/podlators/lib/Pod/Text/Color.pm +++ b/cpan/podlators/lib/Pod/Text/Color.pm @@ -23,7 +23,7 @@ use vars qw(@ISA $VERSION); @ISA = qw(Pod::Text); -$VERSION = '4.13'; +$VERSION = '4.14'; ############################################################################## # Overrides diff --git a/cpan/podlators/lib/Pod/Text/Overstrike.pm b/cpan/podlators/lib/Pod/Text/Overstrike.pm index a0dee0ae8c..53bc6afef2 100644 --- a/cpan/podlators/lib/Pod/Text/Overstrike.pm +++ b/cpan/podlators/lib/Pod/Text/Overstrike.pm @@ -29,7 +29,7 @@ use Pod::Text (); @ISA = qw(Pod::Text); -$VERSION = '4.13'; +$VERSION = '4.14'; ############################################################################## # Overrides diff --git a/cpan/podlators/lib/Pod/Text/Termcap.pm b/cpan/podlators/lib/Pod/Text/Termcap.pm index b9d402ad65..be218f0bf0 100644 --- a/cpan/podlators/lib/Pod/Text/Termcap.pm +++ b/cpan/podlators/lib/Pod/Text/Termcap.pm @@ -24,7 +24,7 @@ use vars qw(@ISA $VERSION); @ISA = qw(Pod::Text); -$VERSION = '4.13'; +$VERSION = '4.14'; ############################################################################## # Overrides diff --git a/cpan/podlators/t/data/snippets/overstrike/tag-width b/cpan/podlators/t/data/snippets/overstrike/tag-width new file mode 100644 index 0000000000..d12b16be8e --- /dev/null +++ b/cpan/podlators/t/data/snippets/overstrike/tag-width @@ -0,0 +1,35 @@ +[name] +Tag width with formatting + +[input] +=head1 TAG WIDTH + +=over 10 + +=item 12345678 + +A + +=item B<12345678> + +B + +=item 1Z<> + +C + +=item B<1> + +D + +=back + +[output] +TTAAGG WWIIDDTTHH + 12345678 A + + 1122334455667788 B + + 1 C + + 11 D diff --git a/cpan/podlators/t/data/snippets/overstrike/wrapping b/cpan/podlators/t/data/snippets/overstrike/wrapping new file mode 100644 index 0000000000..93405f7c8c --- /dev/null +++ b/cpan/podlators/t/data/snippets/overstrike/wrapping @@ -0,0 +1,11 @@ +[name] +Wrapping + +[input] +=head1 WRAPPING + +B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>. + +[output] +WWRRAAPPPPIINNGG + DDoo _n_o_t iinncclluuddee ffoorrmmaattttiinngg ccooddeess wwhheenn wwrraappppiinngg. diff --git a/cpan/podlators/t/data/snippets/text/empty b/cpan/podlators/t/data/snippets/text/empty new file mode 100644 index 0000000000..307e36d293 --- /dev/null +++ b/cpan/podlators/t/data/snippets/text/empty @@ -0,0 +1,7 @@ +[name] +Empty document + +[input] +=pod + +[output] diff --git a/cpan/podlators/t/data/snippets/text/iso-8859-1 b/cpan/podlators/t/data/snippets/text/iso-8859-1 new file mode 100644 index 0000000000..739fa92830 --- /dev/null +++ b/cpan/podlators/t/data/snippets/text/iso-8859-1 @@ -0,0 +1,25 @@ +[name] +ISO-8859-1 encoding + +[input] +=encoding iso-8859-1 + +=head1 ACCENTS + +Beyoncé! Beyoncé! Beyoncé!! + + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + +Older versions didn't convert Beyoncé in verbatim. + +[output] +ACCENTS + Beyoncé! Beyoncé! Beyoncé!! + + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + + Older versions didn't convert Beyoncé in verbatim. diff --git a/cpan/podlators/t/data/snippets/text/utf8-iso b/cpan/podlators/t/data/snippets/text/utf8-iso new file mode 100644 index 0000000000..ba375e49ad --- /dev/null +++ b/cpan/podlators/t/data/snippets/text/utf8-iso @@ -0,0 +1,28 @@ +[name] +ISO-8859-1 encoding with forced UTF-8 output + +[options] +utf8 1 + +[input] +=encoding iso-8859-1 + +=head1 ACCENTS + +Beyoncé! Beyoncé! Beyoncé!! + + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + +Older versions didn't convert Beyoncé in verbatim. + +[output] +ACCENTS + Beyoncé! Beyoncé! Beyoncé!! + + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + Beyoncé! Beyoncé! + + Older versions didn't convert Beyoncé in verbatim. diff --git a/cpan/podlators/t/lib/Test/Podlators.pm b/cpan/podlators/t/lib/Test/Podlators.pm index a7e099daf8..9254f26468 100644 --- a/cpan/podlators/t/lib/Test/Podlators.pm +++ b/cpan/podlators/t/lib/Test/Podlators.pm @@ -91,7 +91,6 @@ sub _stderr_restore { # For the format, see t/data/snippets/README. # # $path - Relative path to read test data from -# $encoding - Encoding of snippet (UTF-8 if not specified) # # Returns: Reference to hash of test data with the following keys: # name - Name of the test for status reporting @@ -101,20 +100,18 @@ sub _stderr_restore { # errors - Expected errors # exception - Text of exception (with file and line stripped) sub read_snippet { - my ($path, $encoding) = @_; + my ($path) = @_; $path = File::Spec->catfile('t', 'data', 'snippets', $path); - $encoding ||= 'UTF-8'; my %data; # Read the sections and store them in the %data hash. my ($line, $section); open(my $fh, '<', $path) or BAIL_OUT("cannot open $path: $!"); while (defined($line = <$fh>)) { - $line = decode($encoding, $line); if ($line =~ m{ \A \s* \[ (\S+) \] \s* \z }xms) { $section = $1; + $data{$section} = q{}; } elsif ($section) { - $data{$section} ||= q{}; $data{$section} .= $line; } } @@ -248,11 +245,17 @@ sub slurp { # $class - Class name of the formatter, as a string # $snippet - Path to the snippet file defining the test # $options_ref - Hash of options with the following keys: -# encoding - Set to use a non-standard encoding +# encoding - Expect the output to be in this non-standard encoding sub test_snippet { my ($class, $snippet, $options_ref) = @_; - my $encoding = defined($options_ref) ? $options_ref->{encoding} : undef; - my $data_ref = read_snippet($snippet, $encoding); + my $data_ref = read_snippet($snippet); + + # Determine the encoding to expect for the output portion of the snippet. + my $encoding; + if (defined($options_ref)) { + $encoding = $options_ref->{encoding}; + } + $encoding ||= 'UTF-8'; # Create the formatter object. my $parser = $class->new(%{ $data_ref->{options} }, name => 'TEST'); @@ -277,7 +280,8 @@ sub test_snippet { $got =~ s{ \n\s+ \z }{\n}xms; # Check the output, errors, and any exception. - is($got, $data_ref->{output}, "$data_ref->{name}: output"); + my $expected = decode($encoding, $data_ref->{output}); + is($got, $expected, "$data_ref->{name}: output"); if ($data_ref->{errors} || $stderr) { is($stderr, $data_ref->{errors} || q{}, "$data_ref->{name}: errors"); } @@ -299,11 +303,19 @@ sub test_snippet { # $class - Class name of the formatter, as a string # $snippet - Path to the snippet file defining the test # $options_ref - Hash of options with the following keys: +# encoding - Expect the snippet to be in this non-standard encoding # perlio_utf8 - Set to 1 to set a PerlIO UTF-8 encoding on the output file sub test_snippet_with_io { my ($class, $snippet, $options_ref) = @_; my $data_ref = read_snippet($snippet); + # Determine the encoding to expect for the output portion of the snippet. + my $encoding; + if (defined($options_ref)) { + $encoding = $options_ref->{encoding}; + } + $encoding ||= 'UTF-8'; + # Create the formatter object. my $parser = $class->new(%{ $data_ref->{options} }, name => 'TEST'); isa_ok($parser, $class, 'Parser object'); @@ -317,7 +329,7 @@ sub test_snippet_with_io { my $input_file = File::Spec->catfile('t', 'tmp', "tmp$$.pod"); open(my $input, '>', $input_file) or BAIL_OUT("cannot create $input_file: $!"); - print {$input} encode('UTF-8', $data_ref->{input}) + print {$input} $data_ref->{input} or BAIL_OUT("cannot write to $input_file: $!"); close($input) or BAIL_OUT("cannot flush output to $input_file: $!"); @@ -336,20 +348,23 @@ sub test_snippet_with_io { $parser->parse_from_file($input_file, $output); close($output) or BAIL_OUT("cannot flush output to $output_file: $!"); - # Read back in the results, checking to ensure that we didn't output the - # accent definitions if we wrote UTF-8 output. + # Read back in the results. For Pod::Man, also ensure that we didn't + # output the accent definitions if we wrote UTF-8 output. open(my $results, '<', $output_file) or BAIL_OUT("cannot open $output_file: $!"); my ($line, $saw_accents); - while (defined($line = <$results>)) { - $line = decode('UTF-8', $line); - if ($line =~ m{ Accent [ ] mark [ ] definitions }xms) { - $saw_accents = 1; + if ($class eq 'Pod::Man') { + while (defined($line = <$results>)) { + $line = decode('UTF-8', $line); + if ($line =~ m{ Accent [ ] mark [ ] definitions }xms) { + $saw_accents = 1; + } + last if $line =~ m{ \A [.]nh }xms; } - last if $line =~ m{ \A [.]nh }xms; } my $saw = do { local $/ = undef; <$results> }; $saw = decode('UTF-8', $saw); + $saw =~ s{ \n\s+ \z }{\n}xms; close($results) or BAIL_OUT("cannot close output file: $!"); # Clean up. @@ -357,12 +372,18 @@ sub test_snippet_with_io { # Check the accent definitions and the output. my $perlio = $options_ref->{perlio_utf8} ? ' (PerlIO)' : q{}; + if ($class eq 'Pod::Man') { + is( + $saw_accents, + $data_ref->{options}{utf8} ? undef : 1, + "$data_ref->{name}: accent definitions$perlio" + ); + } is( - $saw_accents, - $data_ref->{options}{utf8} ? undef : 1, - "$data_ref->{name}: accent definitions$perlio" + $saw, + decode($encoding, $data_ref->{output}), + "$data_ref->{name}: output$perlio" ); - is($saw, $data_ref->{output}, "$data_ref->{name}: output$perlio"); return; } @@ -396,15 +417,12 @@ should be explicitly imported. =over 4 -=item read_snippet(PATH[, ENCODING]) +=item read_snippet(PATH) Read one test snippet from the provided relative file name and return it. The path should be relative to F<t/data/snippets>. For the format, see F<t/data/snippets/README>. -ENCODING, if present, specifies the encoding of the snippet. If not given, -the snippet is assumed to be encoded in C<UTF-8>. - The result will be a hash with the following keys: =over 4 @@ -489,7 +507,7 @@ it, and checking the results. Results are reported with Test::More. OPTIONS, if present, is a reference to a hash of options. Currently, only one key is supported: C<encoding>, which, if set, specifies the encoding of -the snippet. +the output portion of the snippet. =item test_snippet_with_io(CLASS, SNIPPET[, OPTIONS]) @@ -509,7 +527,7 @@ Russ Allbery <rra@cpan.org> =head1 COPYRIGHT AND LICENSE -Copyright 2015-2016, 2018-2019 Russ Allbery <rra@cpan.org> +Copyright 2015-2016, 2018-2020 Russ Allbery <rra@cpan.org> This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. diff --git a/cpan/podlators/t/man/iso-8859-1.t b/cpan/podlators/t/man/iso-8859-1.t index da23190d16..2b2106f14f 100644 --- a/cpan/podlators/t/man/iso-8859-1.t +++ b/cpan/podlators/t/man/iso-8859-1.t @@ -24,4 +24,4 @@ BEGIN { } # Test the snippet with the proper encoding. -test_snippet('Pod::Man', 'man/iso-8859-1', { encoding => 'iso-8859-1' }); +test_snippet('Pod::Man', 'man/iso-8859-1'); diff --git a/cpan/podlators/t/man/utf8-io.t b/cpan/podlators/t/man/utf8-io.t index 58369310ce..76e21b98f0 100644 --- a/cpan/podlators/t/man/utf8-io.t +++ b/cpan/podlators/t/man/utf8-io.t @@ -1,8 +1,8 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # # Test Pod::Man UTF-8 handling, with and without PerlIO. # -# Copyright 2002, 2004, 2006, 2008-2010, 2012, 2014-2015, 2018-2019 +# Copyright 2002, 2004, 2006, 2008-2010, 2012, 2014-2015, 2018-2020 # Russ Allbery <rra@cpan.org> # # This program is free software; you may redistribute it and/or modify it diff --git a/cpan/podlators/t/parselink/basic.t b/cpan/podlators/t/parselink/basic.t index 48fbb37f13..0f39e56397 100644 --- a/cpan/podlators/t/parselink/basic.t +++ b/cpan/podlators/t/parselink/basic.t @@ -1,122 +1,120 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # -# parselink.t -- Tests for Pod::ParseLink. +# Tests for Pod::ParseLink. # -# Copyright 2001, 2009, 2018 by Russ Allbery <rra@cpan.org> +# Copyright 2001, 2009, 2018, 2020 by Russ Allbery <rra@cpan.org> # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. # # SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl -# The format of each entry in this array is the L<> text followed by the -# five-element parse returned by parselink. -our @TESTS = ( - [ 'foo', - undef, 'foo', 'foo', undef, 'pod' ], - - [ 'foo|bar', - 'foo', 'foo', 'bar', undef, 'pod' ], - - [ 'foo/bar', - undef, '"bar" in foo', 'foo', 'bar', 'pod' ], - - [ 'foo/"baz boo"', - undef, '"baz boo" in foo', 'foo', 'baz boo', 'pod' ], - - [ '/bar', - undef, '"bar"', undef, 'bar', 'pod' ], - - [ '/"baz boo"', - undef, '"baz boo"', undef, 'baz boo', 'pod' ], - - [ '/baz boo', - undef, '"baz boo"', undef, 'baz boo', 'pod' ], - - [ 'foo bar/baz boo', - undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ], - - [ 'foo bar / baz boo', - undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ], - - [ "foo\nbar\nbaz\n/\nboo", - undef, '"boo" in foo bar baz', 'foo bar baz', 'boo', 'pod' ], - - [ 'anchor|name/section', - 'anchor', 'anchor', 'name', 'section', 'pod' ], - - [ '"boo var baz"', - undef, '"boo var baz"', undef, 'boo var baz', 'pod' ], - - [ 'bar baz', - undef, '"bar baz"', undef, 'bar baz', 'pod' ], - - [ '"boo bar baz / baz boo"', - undef, '"boo bar baz / baz boo"', undef, 'boo bar baz / baz boo', - 'pod' ], - - [ 'fooZ<>bar', - undef, 'fooZ<>bar', 'fooZ<>bar', undef, 'pod' ], - - [ 'Testing I<italics>|foo/bar', - 'Testing I<italics>', 'Testing I<italics>', 'foo', 'bar', 'pod' ], - - [ 'foo/I<Italic> text', - undef, '"I<Italic> text" in foo', 'foo', 'I<Italic> text', 'pod' ], - - [ 'fooE<verbar>barZ<>/Section C<with> I<B<other> markup', - undef, '"Section C<with> I<B<other> markup" in fooE<verbar>barZ<>', - 'fooE<verbar>barZ<>', 'Section C<with> I<B<other> markup', 'pod' ], - - [ 'Nested L<http://www.perl.org/>|fooE<sol>bar', - 'Nested L<http://www.perl.org/>', 'Nested L<http://www.perl.org/>', - 'fooE<sol>bar', undef, 'pod' ], - - [ 'ls(1)', - undef, 'ls(1)', 'ls(1)', undef, 'man' ], - - [ ' perlfunc(1)/open ', - undef, '"open" in perlfunc(1)', 'perlfunc(1)', 'open', 'man' ], - - [ 'some manual page|perl(1)', - 'some manual page', 'some manual page', 'perl(1)', undef, 'man' ], - - [ 'http://www.perl.org/', - undef, 'http://www.perl.org/', 'http://www.perl.org/', undef, 'url' ], - - [ 'news:yld72axzc8.fsf@windlord.stanford.edu', - undef, 'news:yld72axzc8.fsf@windlord.stanford.edu', - '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' ], +use 5.008; +use strict; +use warnings; - [ '0|Pod::Parser', - '0', '0', 'Pod::Parser', undef, 'pod' ], -); +use Test::More tests => 28; BEGIN { - chdir 't' if -d 't'; - unshift (@INC, '../blib/lib'); - $| = 1; + use_ok('Pod::ParseLink'); } -use strict; - -use Test::More tests => 28; -BEGIN { use_ok ('Pod::ParseLink') } - -# Used for reporting test failures. -my @names = qw(text inferred name section type); +# The format of each entry in this array is the L<> text followed by the +# five-element parse returned by parselink. +our @TESTS = ( + ['foo' => (undef, 'foo', 'foo', undef, 'pod')], + ['foo|bar' => ('foo', 'foo', 'bar', undef, 'pod')], + ['foo/bar' => (undef, '"bar" in foo', 'foo', 'bar', 'pod')], + ['foo/"baz boo"' => (undef, '"baz boo" in foo', 'foo', 'baz boo', 'pod')], + ['/bar' => (undef, '"bar"', undef, 'bar', 'pod')], + ['/"baz boo"' => (undef, '"baz boo"', undef, 'baz boo', 'pod')], + ['/baz boo', => (undef, '"baz boo"', undef, 'baz boo', 'pod')], + [ + 'foo bar/baz boo' => + (undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod') + ], + [ + 'foo bar / baz boo' => + (undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod') + ], + [ + "foo\nbar\nbaz\n/\nboo" => + (undef, '"boo" in foo bar baz', 'foo bar baz', 'boo', 'pod') + ], + ['anchor|name/section' => qw(anchor anchor name section pod)], + ['"boo var baz"' => (undef, '"boo var baz"', undef, 'boo var baz', 'pod')], + ['bar baz' => (undef, '"bar baz"', undef, 'bar baz', 'pod')], + [ + '"boo bar baz / baz boo"' => ( + undef, '"boo bar baz / baz boo"', + undef, 'boo bar baz / baz boo', + 'pod', + ) + ], + ['fooZ<>bar' => (undef, 'fooZ<>bar', 'fooZ<>bar', undef, 'pod')], + [ + 'Testing I<italics>|foo/bar' => + ('Testing I<italics>', 'Testing I<italics>', 'foo', 'bar', 'pod') + ], + [ + 'foo/I<Italic> text' => + (undef, '"I<Italic> text" in foo', 'foo', 'I<Italic> text', 'pod') + ], + [ + 'fooE<verbar>barZ<>/Section C<with> I<B<other> markup' => ( + undef, + '"Section C<with> I<B<other> markup" in fooE<verbar>barZ<>', + 'fooE<verbar>barZ<>', + 'Section C<with> I<B<other> markup', + 'pod', + ) + ], + [ + 'Nested L<http://www.perl.org/>|fooE<sol>bar' => ( + 'Nested L<http://www.perl.org/>', + 'Nested L<http://www.perl.org/>', + 'fooE<sol>bar', undef, 'pod', + ) + ], + ['ls(1)' => (undef, 'ls(1)', 'ls(1)', undef, 'man')], + [ + ' perlfunc(1)/open ' => + (undef, '"open" in perlfunc(1)', 'perlfunc(1)', 'open', 'man') + ], + [ + 'some manual page|perl(1)' => + ('some manual page', 'some manual page', 'perl(1)', undef, 'man') + ], + [ + 'http://www.perl.org/' => ( + undef, 'http://www.perl.org/', 'http://www.perl.org/', undef, + 'url', + ) + ], + [ + 'news:yld72axzc8.fsf@windlord.stanford.edu' => ( + undef, + 'news:yld72axzc8.fsf@windlord.stanford.edu', + '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')], +); -for (@TESTS) { - my @expected = @$_; - my $link = shift @expected; - my @results = parselink ($link); - my $pretty = $link; - $pretty =~ s/\n/\\n/g; - is_deeply (\@results, \@expected, $pretty); +# Run all of the tests. +for my $test (@TESTS) { + my ($link, @expected) = @$test; + my @results = parselink($link); + my $pretty = $link; + $pretty =~ s{\n}{\\n}xmsg; + is_deeply(\@results, \@expected, $pretty); } diff --git a/cpan/podlators/t/text/empty.t b/cpan/podlators/t/text/empty.t deleted file mode 100644 index e03a03c4a3..0000000000 --- a/cpan/podlators/t/text/empty.t +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/perl -w -# -# Test Pod::Text with a document that produces only errors. -# -# Copyright 2013, 2018 Russ Allbery <rra@cpan.org> -# -# This program is free software; you may redistribute it and/or modify it -# under the same terms as Perl itself. -# -# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl - -BEGIN { - chdir 't' if -d 't'; - if ($ENV{PERL_CORE}) { - @INC = '../lib'; - } - unshift (@INC, '../blib/lib'); - $| = 1; -} - -use strict; - -use Test::More tests => 8; -BEGIN { use_ok ('Pod::Text') } - -# Set up Pod::Text to output to a string. -my $parser = Pod::Text->new; -isa_ok ($parser, 'Pod::Text'); -my $output; -$parser->output_string (\$output); - -# Try a POD document where the only command is invalid. Be sure that we don't -# get any warnings as well as any errors. -local $SIG{__WARN__} = sub { die $_[0] }; -ok (eval { $parser->parse_string_document("=\xa0") }, - 'Parsed invalid document'); -is ($@, '', '...with no errors'); -SKIP: { - skip 'Pod::Simple does not produce errors for invalid commands', 1 - if $output eq q{}; - like ($output, qr{POD ERRORS}, - '...and output contains a POD ERRORS section'); -} - -# Try with a document containing only =cut. -ok (eval { $parser->parse_string_document("=cut") }, - 'Parsed invalid document'); -is ($@, '', '...with no errors'); -SKIP: { - skip 'Pod::Simple does not produce errors for invalid commands', 1 - if $output eq q{}; - like ($output, qr{POD ERRORS}, - '...and output contains a POD ERRORS section'); -} diff --git a/cpan/podlators/t/text/invalid.t b/cpan/podlators/t/text/invalid.t new file mode 100644 index 0000000000..27a4e820fa --- /dev/null +++ b/cpan/podlators/t/text/invalid.t @@ -0,0 +1,61 @@ +#!/usr/bin/perl -w +# +# Test Pod::Text with a document that produces only errors. +# +# Documents with only errors were shown as contentless but had a POD ERRORS +# section, which previously led to internal errors because state variables +# weren't properly initialized. See CPAN RT #88724. +# +# Copyright 2013, 2018, 2020 Russ Allbery <rra@cpan.org> +# +# This program is free software; you may redistribute it and/or modify it +# under the same terms as Perl itself. +# +# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl + +use 5.008; +use strict; +use warnings; + +use Test::More tests => 8; + +BEGIN { + use_ok('Pod::Text'); +} + +# Set up Pod::Text to output to a string. +my $parser = Pod::Text->new; +isa_ok($parser, 'Pod::Text'); +my $output; +$parser->output_string(\$output); + +# Ensure any warnings cause a test failure. +## no critic (ErrorHandling::RequireCarping) +local $SIG{__WARN__} = sub { die $_[0] }; + +# Parse a document provided as a string, ensure that it doesn't produce any +# warnings or errors, and check that it either contains no content or a POD +# ERRORS section. +# +# $document - Document to parse +# $name - Name of the test +sub check_document { + my ($document, $name) = @_; + my $result = eval { $parser->parse_string_document($document) }; + ok($result, "Parsed $name"); + is($@, q{}, 'No exceptions'); + if ($output eq q{}) { + # Older Pod::Simple doesn't always produce errors. + ok(1, 'Output is empty'); + } else { + like($output, qr{POD [ ] ERRORS}xms, 'Output contains POD ERRORS'); + } + return; +} + +# Document whose only content is an invalid command. +## no critic (ValuesAndExpressions::ProhibitEscapedCharacters) +check_document("=\xa0", 'invalid command'); + +# Document containing only a =cut. +check_document('=cut', 'document with only =cut'); diff --git a/cpan/podlators/t/text/iso-8859-1.t b/cpan/podlators/t/text/iso-8859-1.t new file mode 100644 index 0000000000..889d553bd8 --- /dev/null +++ b/cpan/podlators/t/text/iso-8859-1.t @@ -0,0 +1,27 @@ +#!/usr/bin/perl +# +# Test Pod::Text ISO-8859-1 handling +# +# Copyright 2016, 2019 Russ Allbery <rra@cpan.org> +# +# This program is free software; you may redistribute it and/or modify it +# under the same terms as Perl itself. +# +# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl + +use 5.008; +use strict; +use warnings; + +use lib 't/lib'; + +use Test::More tests => 3; +use Test::Podlators qw(test_snippet); + +# Load the module. +BEGIN { + use_ok('Pod::Text'); +} + +# Test the snippet with the proper encoding. +test_snippet('Pod::Text', 'text/iso-8859-1', { encoding => 'iso-8859-1' }); diff --git a/cpan/podlators/t/text/overstrike.t b/cpan/podlators/t/text/overstrike.t index 7433264cb3..7cdaa538b2 100644 --- a/cpan/podlators/t/text/overstrike.t +++ b/cpan/podlators/t/text/overstrike.t @@ -1,8 +1,8 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # -# Additional specialized tests for Pod::Text::Overstrike. +# Test Pod::Text::Overstrike with various snippets. # -# Copyright 2002, 2004, 2006, 2009, 2012-2013, 2018 +# Copyright 2002, 2004, 2006, 2009, 2012-2013, 2018-2019 # Russ Allbery <rra@cpan.org> # # This program is free software; you may redistribute it and/or modify it @@ -10,97 +10,23 @@ # # SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl -BEGIN { - chdir 't' if -d 't'; - if ($ENV{PERL_CORE}) { - @INC = '../lib'; - } - unshift (@INC, '../blib/lib'); - $| = 1; -} - +use 5.008; use strict; +use warnings; -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 +use lib 't/lib'; -=item 12345678 +use Test::More tests => 5; +use Test::Podlators qw(test_snippet); -A - -=item B<12345678> - -B - -=item 1Z<> - -C - -=item B<1> - -D - -=back -### -TTAAGG WWIIDDTTHH - 12345678 A - - 1122334455667788 B - - 1 C +BEGIN { + use_ok('Pod::Text::Overstrike'); +} - 11 D +# List of snippets run by this test. +my @snippets = qw(tag-width wrapping); -### +# Run all the tests. +for my $snippet (@snippets) { + test_snippet('Pod::Text::Overstrike', "overstrike/$snippet"); +} diff --git a/cpan/podlators/t/text/perlio.t b/cpan/podlators/t/text/perlio.t deleted file mode 100644 index 1b6523d328..0000000000 --- a/cpan/podlators/t/text/perlio.t +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/perl -w -# -# Test Pod::Text with a PerlIO UTF-8 encoding layer. -# -# Copyright 2002, 2004, 2006-2010, 2012, 2014, 2018 -# Russ Allbery <rra@cpan.org> -# -# This program is free software; you may redistribute it and/or modify it -# under the same terms as Perl itself. -# -# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl - -BEGIN { - chdir 't' if -d 't'; - if ($ENV{PERL_CORE}) { - @INC = '../lib'; - } - unshift (@INC, '../blib/lib'); - $| = 1; -} - -use strict; - -use Test::More; - -# 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') } - -# Force UTF-8 on all relevant file handles. Hide this in a string eval so -# that older versions of Perl don't croak and minimum-version tests still -# pass. -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 $parser = Pod::Text->new (utf8 => 1); -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"; - eval 'binmode (\*TMP, ":encoding(utf-8)")'; - print TMP "=encoding UTF-8\n\n"; - while (<DATA>) { - last if $_ eq "###\n"; - print TMP $_; - } - close TMP; - open (OUT, "> out$$.tmp") or die "Cannot create out$$.tmp: $!\n"; - eval 'binmode (\*OUT, ":encoding(utf-8)")'; - $parser->parse_from_file ("tmp$$.pod", \*OUT); - close OUT; - open (TMP, "out$$.tmp") or die "Cannot open out$$.tmp: $!\n"; - eval 'binmode (\*TMP, ":encoding(utf-8)")'; - 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 text output. -# This is used to test specific features or problems with Pod::Text. The -# input and output are separated by lines containing only ###. - -__DATA__ - -### -=head1 Test of SE<lt>E<gt> - -This is S<some whitespace>. -### -Test of S<> - This is some whitespace. - -### - -### -=head1 I can eat glass - -=over 4 - -=item Esperanto - -Mi povas manÄi vitron, Äi ne damaÄas min. - -=item Braille - -⠊⠀⠉â â ⠀⠑â ⠞⠀⠛⠇â â Žâ Žâ €â â ⠙⠀⠊⠞⠀⠙⠕⠑⠎â ⠞⠀⠓⠥⠗⠞⠀â â ‘ - -=item Hindi - -मैं काà¤à¤š खा सकता हूठऔर मà¥à¤à¥‡ उससे कोई चोट नहीं पहà¥à¤‚चती. - -=back - -See L<http://www.columbia.edu/kermit/utf8.html> -### -I can eat glass - Esperanto - Mi povas manÄi vitron, Äi ne damaÄas min. - - Braille - ⠊⠀⠉â â ⠀⠑â ⠞⠀⠛⠇â â Žâ Žâ €â â ⠙⠀⠊⠞⠀⠙⠕⠑⠎â ⠞⠀⠓⠥⠗⠞⠀â â ‘ - - Hindi - मैं काà¤à¤š खा सकता हूठऔर मà¥à¤à¥‡ उससे कोई चोट नहीं पहà¥à¤‚चती. - - See <http://www.columbia.edu/kermit/utf8.html> - -### diff --git a/cpan/podlators/t/text/snippets.t b/cpan/podlators/t/text/snippets.t index 19fd7c879b..7667de794e 100644 --- a/cpan/podlators/t/text/snippets.t +++ b/cpan/podlators/t/text/snippets.t @@ -2,7 +2,7 @@ # # Test Pod::Text behavior with various snippets. # -# Copyright 2002, 2004, 2006-2009, 2012, 2018-2019 +# Copyright 2002, 2004, 2006-2009, 2012, 2018-2020 # Russ Allbery <rra@cpan.org> # # This program is free software; you may redistribute it and/or modify it @@ -16,7 +16,7 @@ use warnings; use lib 't/lib'; -use Test::More tests => 51; +use Test::More tests => 53; use Test::Podlators qw(test_snippet); # Load the module. @@ -26,7 +26,7 @@ BEGIN { # List of snippets run by this test. my @snippets = qw( - alt c-with-spaces code cpp error-die error-none error-normal error-pod + alt c-with-spaces code cpp empty error-die error-none error-normal error-pod error-stderr error-stderr-opt for late-encoding link-rt link-url margin nonbreaking-space nourls periods quotes-opt s-whitespace sentence-spacing utf8 verbatim diff --git a/cpan/podlators/t/text/utf8-io.t b/cpan/podlators/t/text/utf8-io.t new file mode 100644 index 0000000000..2e59c41700 --- /dev/null +++ b/cpan/podlators/t/text/utf8-io.t @@ -0,0 +1,48 @@ +#!/usr/bin/perl +# +# Test Pod::Text UTF-8 handling, with and without PerlIO. +# +# Copyright 2002, 2004, 2006-2010, 2012, 2014, 2018, 2020 +# Russ Allbery <rra@cpan.org> +# +# This program is free software; you may redistribute it and/or modify it +# under the same terms as Perl itself. +# +# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl + +use 5.008; +use strict; +use warnings; + +use lib 't/lib'; + +use Test::More tests => 17; +use Test::Podlators qw(test_snippet_with_io); + +BEGIN { + use_ok('Pod::Text'); +} + +# Force UTF-8 on all relevant file handles. Hide this in a string eval so +# that older versions of Perl don't croak and minimum-version tests still +# pass. +# +## no critic (BuiltinFunctions::ProhibitStringyEval) +## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars) +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)")'; +## use critic + +# For each of the UTF-8 snippets, check them with and without PerlIO layers. +for my $snippet (qw(late-encoding s-whitespace utf8)) { + test_snippet_with_io('Pod::Text', "text/$snippet"); + test_snippet_with_io('Pod::Text', "text/$snippet", { perlio_utf8 => 1 }); +} + +# Load a snippet in ISO 8859-1 that forces the output to be in UTF-8. +test_snippet_with_io('Pod::Text', 'text/utf8-iso', + { encoding => 'iso-8859-1' }); +test_snippet_with_io('Pod::Text', 'text/utf8-iso', + { encoding => 'iso-8859-1', perlio_utf8 => 1 }); |