diff options
author | Karen Etheridge <ether@cpan.org> | 2015-12-19 19:08:24 -0800 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2016-01-01 21:17:23 -0500 |
commit | cb21ff4630e9dc4048595dd175a4ee716bd54ba2 (patch) | |
tree | 85a720ceb5653b5867150307d5dc6f902aad02a6 /cpan/podlators/t/text | |
parent | b0248dbfdf5ebb72be4ef440747e59fd3204ee95 (diff) | |
download | perl-cb21ff4630e9dc4048595dd175a4ee716bd54ba2.tar.gz |
Update podlators to version 4.03
Diffstat (limited to 'cpan/podlators/t/text')
-rw-r--r-- | cpan/podlators/t/text/basic.t | 155 | ||||
-rw-r--r-- | cpan/podlators/t/text/color.t | 114 | ||||
-rw-r--r-- | cpan/podlators/t/text/empty.t | 52 | ||||
-rw-r--r-- | cpan/podlators/t/text/encoding.t | 156 | ||||
-rw-r--r-- | cpan/podlators/t/text/options.t | 366 | ||||
-rw-r--r-- | cpan/podlators/t/text/overstrike.t | 104 | ||||
-rw-r--r-- | cpan/podlators/t/text/perlio.t | 127 | ||||
-rw-r--r-- | cpan/podlators/t/text/termcap.t | 125 | ||||
-rw-r--r-- | cpan/podlators/t/text/utf8.t | 126 |
9 files changed, 1325 insertions, 0 deletions
diff --git a/cpan/podlators/t/text/basic.t b/cpan/podlators/t/text/basic.t new file mode 100644 index 0000000000..1d274c3e5c --- /dev/null +++ b/cpan/podlators/t/text/basic.t @@ -0,0 +1,155 @@ +#!/usr/bin/perl -w +# +# text.t -- Additional specialized tests for Pod::Text. +# +# Copyright 2002, 2004, 2006, 2007, 2008, 2009, 2012 +# 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. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } + unshift (@INC, '../blib/lib'); + $| = 1; +} + +use strict; + +use Pod::Simple; +use Test::More tests => 9; +BEGIN { use_ok ('Pod::Text') } + +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"; + 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 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 PERIODS + +This C<.> should be quoted. +### +PERIODS + This "." should be quoted. + +### + +### +=head1 CE<lt>E<gt> WITH SPACES + +What does C<< this. >> end up looking like? +### +C<> WITH SPACES + What does "this." end up looking like? + +### + +### +=head1 Test of SE<lt>E<gt> + +This is some S< > whitespace. +### +Test of S<> + This is some whitespace. + +### + +### +=head1 Test of =for + +=for comment +This won't be seen. + +Yes. + +=for text +This should be seen. + +=for TEXT As should this. + +=for man +But this shouldn't. + +Some more text. +### +Test of =for + Yes. + +This should be seen. +As should this. + Some more text. + +### + +### +=pod + +text + + line1 + + line3 +### + text + + line1 + + 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. + +### + +### +=head1 RT LINK + +L<[perl #12345]|https://rt.cpan.org/12345> +### +RT LINK + [perl #12345] <https://rt.cpan.org/12345> + +### diff --git a/cpan/podlators/t/text/color.t b/cpan/podlators/t/text/color.t new file mode 100644 index 0000000000..c2e13335ad --- /dev/null +++ b/cpan/podlators/t/text/color.t @@ -0,0 +1,114 @@ +#!/usr/bin/perl -w +# +# color.t -- Additional specialized tests for Pod::Text::Color. +# +# Copyright 2002, 2004, 2006, 2009, 2012, 2013 +# 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. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } + unshift (@INC, '../blib/lib'); + $| = 1; +} + +use strict; + +use Test::More; + +# Skip this test if Term::ANSIColor isn't available. +eval { require Term::ANSIColor }; +if ($@) { + plan skip_all => 'Term::ANSIColor required for Pod::Text::Color'; +} else { + plan tests => 4; +} +require_ok ('Pod::Text::Color'); + +# 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"; + 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::Color. 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>>. +### +[1mWRAPPING[0m + [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 1Z<> + +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/text/empty.t b/cpan/podlators/t/text/empty.t new file mode 100644 index 0000000000..0b8823a3e5 --- /dev/null +++ b/cpan/podlators/t/text/empty.t @@ -0,0 +1,52 @@ +#!/usr/bin/perl -w +# +# text-empty.t -- Test Pod::Text with a document that produces only errors. +# +# Copyright 2013 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. + +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/encoding.t b/cpan/podlators/t/text/encoding.t new file mode 100644 index 0000000000..7fe7401d59 --- /dev/null +++ b/cpan/podlators/t/text/encoding.t @@ -0,0 +1,156 @@ +#!/usr/bin/perl -w +# +# text-encoding.t -- Test Pod::Text with various weird encoding combinations. +# +# Copyright 2002, 2004, 2006, 2007, 2008, 2009, 2012, 2015 +# 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. + +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 encoding support'; + } else { + plan tests => 7; + } +} +BEGIN { use_ok ('Pod::Text') } + +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; + 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>) { + last if $_ eq "###\n"; + print TMP $_; + } + close TMP; + open (OUT, "> out$$.tmp") or die "Cannot create out$$.tmp: $!\n"; + eval { binmode (\*OUT, ':raw') }; + $parser->parse_from_file ("tmp$$.pod", \*OUT); + close OUT; + open (TMP, "out$$.tmp") or die "Cannot open out$$.tmp: $!\n"; + eval { binmode (\*TMP, ':raw') }; + 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. + +### + +### +=encoding utf-8 + +=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> + +### + +### +=pod + +=head1 NAME + +This is the first ascii text + +=encoding utf8 + +=over 4 + +=item ⇒This is the first non-ascii text⇐ + +This is the second ascii text + +=back + +=cut +### +NAME + This is the first ascii text + + ⇒This is the first non-ascii text⇐ + This is the second ascii text + +### diff --git a/cpan/podlators/t/text/options.t b/cpan/podlators/t/text/options.t new file mode 100644 index 0000000000..3338aa63c2 --- /dev/null +++ b/cpan/podlators/t/text/options.t @@ -0,0 +1,366 @@ +#!/usr/bin/perl -w +# +# Additional tests for Pod::Text options. +# +# Copyright 2002, 2004, 2006, 2008, 2009, 2012, 2013, 2015 +# 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. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } + unshift (@INC, '../blib/lib'); + $| = 1; +} + +use strict; + +use Test::More tests => 37; +BEGIN { use_ok ('Pod::Text') } + +# Redirect stderr to a file. +sub stderr_save { + open (OLDERR, '>&STDERR') or die "Can't dup STDERR: $!\n"; + open (STDERR, "> out$$.err") or die "Can't redirect STDERR: $!\n"; +} + +# Restore stderr. +sub stderr_restore { + close STDERR; + open (STDERR, '>&OLDERR') or die "Can't dup STDERR: $!\n"; + close OLDERR; +} + +my $n = 1; +while (<DATA>) { + my %options; + next until $_ eq "###\n"; + while (<DATA>) { + last if $_ eq "###\n"; + my ($option, $value) = split; + $options{$option} = $value; + } + open (TMP, "> tmp$$.pod") or die "Cannot create tmp$$.pod: $!\n"; + while (<DATA>) { + last if $_ eq "###\n"; + print TMP $_; + } + close TMP; + 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; + eval { $parser->parse_from_file ("tmp$$.pod", \*OUT) }; + my $exception = $@; + stderr_restore; + 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, "Ouput correct for test $n"); + open (ERR, "out$$.err") or die "Cannot open out$$.err: $!\n"; + my $errors; + { + local $/; + $errors = <ERR>; + } + close ERR; + $errors =~ s/\Qtmp$$.pod/tmp.pod/g; + 1 while unlink ("out$$.err"); + if ($exception) { + $exception =~ s/ at .*//; + $errors .= "EXCEPTION: $exception"; + } + $expected = ''; + while (<DATA>) { + last if $_ eq "###\n"; + $expected .= $_; + } + 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 +# options, input, output, and errors are separated by lines containing only +# ###. + +__DATA__ + +### +alt 1 +### +=head1 SAMPLE + +=over 4 + +=item F + +Paragraph. + +=item Bar + +=item B + +Paragraph. + +=item Longer + +Paragraph. + +=back + +### + +==== SAMPLE ==== + +: F Paragraph. + +: Bar +: B Paragraph. + +: Longer + Paragraph. + +### +### + +### +margin 4 +### +=head1 SAMPLE + +This is some body text that is long enough to be a paragraph that wraps, +thereby testing margins with wrapped paragraphs. + + This is some verbatim text. + +=over 6 + +=item Test + +This is a test of an indented paragraph. + +This is another indented paragraph. + +=back +### + SAMPLE + This is some body text that is long enough to be a paragraph that + wraps, thereby testing margins with wrapped paragraphs. + + This is some verbatim text. + + Test This is a test of an indented paragraph. + + This is another indented paragraph. + +### +### + +### +code 1 +### +This is some random text. +This is more random text. + +This is some random text. +This is more random text. + +=head1 SAMPLE + +This is POD. + +=cut + +This is more random text. +### +This is some random text. +This is more random text. + +This is some random text. +This is more random text. + +SAMPLE + This is POD. + + +This is more random text. +### +### + +### +sentence 1 +### +=head1 EXAMPLE + +Whitespace around C<< this. >> must be ignored per perlpodspec. >> +needs to eat all of the space in front of it. + +=cut +### +EXAMPLE + Whitespace around "this." must be ignored per perlpodspec. >> needs to + eat all of the space in front of it. + +### +### + +### +### +=over 4 + +=item Foo + +Bar. + +=head1 NEXT +### + Foo Bar. + +NEXT +POD ERRORS + Hey! The above document had some coding errors, which are explained + below: + + Around line 7: + You forgot a '=back' before '=head1' + +### +### + +### +stderr 1 +### +=over 4 + +=item Foo + +Bar. + +=head1 NEXT +### + Foo Bar. + +NEXT +### +tmp.pod around line 7: You forgot a '=back' before '=head1' +### + +### +nourls 1 +### +=head1 URL suppression + +L<anchor|http://www.example.com/> +### +URL suppression + anchor + +### +### + +### +errors stderr +### +=over 4 + +=item Foo + +Bar. + +=head1 NEXT +### + Foo Bar. + +NEXT +### +tmp.pod around line 7: You forgot a '=back' before '=head1' +### + +### +errors die +### +=over 4 + +=item Foo + +Bar. + +=head1 NEXT +### + Foo Bar. + +NEXT +### +tmp.pod around line 7: You forgot a '=back' before '=head1' +EXCEPTION: POD document had syntax errors +### + +### +errors pod +### +=over 4 + +=item Foo + +Bar. + +=head1 NEXT +### + Foo Bar. + +NEXT +POD ERRORS + Hey! The above document had some coding errors, which are explained + below: + + Around line 7: + You forgot a '=back' before '=head1' + +### +### + +### +errors none +### +=over 4 + +=item Foo + +Bar. + +=head1 NEXT +### + Foo Bar. + +NEXT +### +### + +### +quotes <<<>>> +### +=head1 FOO C<BAR> BAZ + +Foo C<bar> baz. +### +FOO <<<BAR>>> BAZ + Foo <<<bar>>> baz. + +### +### diff --git a/cpan/podlators/t/text/overstrike.t b/cpan/podlators/t/text/overstrike.t new file mode 100644 index 0000000000..c5496bb871 --- /dev/null +++ b/cpan/podlators/t/text/overstrike.t @@ -0,0 +1,104 @@ +#!/usr/bin/perl -w +# +# overstrike.t -- Additional specialized tests for Pod::Text::Overstrike. +# +# Copyright 2002, 2004, 2006, 2009, 2012, 2013 +# 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. + +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 1Z<> + +C + +=item B<1> + +D + +=back +### +TTAAGG WWIIDDTTHH + 12345678 A + + 1122334455667788 B + + 1 C + + 11 D + +### diff --git a/cpan/podlators/t/text/perlio.t b/cpan/podlators/t/text/perlio.t new file mode 100644 index 0000000000..c95f682b68 --- /dev/null +++ b/cpan/podlators/t/text/perlio.t @@ -0,0 +1,127 @@ +#!/usr/bin/perl -w +# +# text-perlio.t -- Test Pod::Text with a PerlIO UTF-8 encoding layer. +# +# Copyright 2002, 2004, 2006, 2007, 2008, 2009, 2010, 2012, 2014 +# 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. + +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/termcap.t b/cpan/podlators/t/text/termcap.t new file mode 100644 index 0000000000..4b30c62fc3 --- /dev/null +++ b/cpan/podlators/t/text/termcap.t @@ -0,0 +1,125 @@ +#!/usr/bin/perl -w +# +# termcap.t -- Additional specialized tests for Pod::Text::Termcap. +# +# Copyright 2002, 2004, 2006, 2009, 2012, 2013, 2014 +# 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. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } + unshift (@INC, '../blib/lib'); + $| = 1; +} + +use strict; + +use File::Spec; +use Test::More tests => 4; + +BEGIN { 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. +sub source_path { + my $file = shift; + if ($ENV{PERL_CORE}) { + my $updir = File::Spec->updir; + my $dir = File::Spec->catdir ($updir, 'lib', 'Pod', 't', 'data'); + return File::Spec->catfile ($dir, $file); + } else { + return File::Spec->catfile ('data', $file); + } +} + +# Hard-code a few values to try to get reproducible results. +$ENV{COLUMNS} = 80; +$ENV{TERM} = 'xterm'; +$ENV{TERMPATH} = source_path ('termcap'); +$ENV{TERMCAP} = 'xterm:co=#80:do=^J:md=\E[1m:us=\E[4m:me=\E[m'; + +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"; + 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>>. +### +[1mWRAPPING[m + [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 1Z<> + +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/utf8.t b/cpan/podlators/t/text/utf8.t new file mode 100644 index 0000000000..e468c57d0d --- /dev/null +++ b/cpan/podlators/t/text/utf8.t @@ -0,0 +1,126 @@ +#!/usr/bin/perl -w +# +# text-utf8.t -- Test Pod::Text with UTF-8 input. +# +# Copyright 2002, 2004, 2006, 2007, 2008, 2009, 2012, 2014 +# 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. + +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; +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"; + $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> + +### |