Update to podlators 2.3.0
[p5sagit/p5-mst-13.2.git] / cpan / podlators / t / text-encoding.t
CommitLineData
9f2f055a 1#!/usr/bin/perl -w
2#
3# text-encoding.t -- Test Pod::Text with various weird encoding combinations.
4#
fe61459e 5# Copyright 2002, 2004, 2006, 2007, 2008, 2009
6# Russ Allbery <rra@stanford.edu>
9f2f055a 7#
8# This program is free software; you may redistribute it and/or modify it
9# under the same terms as Perl itself.
10
11BEGIN {
12 chdir 't' if -d 't';
13 if ($ENV{PERL_CORE}) {
14 @INC = '../lib';
9f2f055a 15 }
16 unshift (@INC, '../blib/lib');
17 $| = 1;
9f2f055a 18}
19
fe61459e 20use strict;
9f2f055a 21
fe61459e 22use Test::More;
9f2f055a 23
fe61459e 24# UTF-8 support requires Perl 5.8 or later.
25BEGIN {
26 if ($] < 5.008) {
27 plan skip_all => 'Perl 5.8 required for encoding support';
28 } else {
29 plan tests => 7;
30 }
31}
32BEGIN { use_ok ('Pod::Text') }
9f2f055a 33
9f2f055a 34eval { binmode (\*DATA, ':raw') };
35eval { binmode (\*STDOUT, ':raw') };
fe61459e 36my $builder = Test::More->builder;
37eval { binmode ($builder->output, ':raw') };
38eval { binmode ($builder->failure_output, ':raw') };
39
40my $n = 1;
9f2f055a 41while (<DATA>) {
42 my %opts;
fe61459e 43 $opts{utf8} = 1 if $n == 3;
9f2f055a 44 next until $_ eq "###\n";
fe61459e 45 my $parser = Pod::Text->new (%opts);
46 isa_ok ($parser, 'Pod::Text', 'Parser object');
9f2f055a 47 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
48 eval { binmode (\*TMP, ':raw') };
49 while (<DATA>) {
50 last if $_ eq "###\n";
51 print TMP $_;
52 }
53 close TMP;
54 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
2dab2cc1 55 eval { binmode (\*OUT, ':raw') };
9f2f055a 56 $parser->parse_from_file ('tmp.pod', \*OUT);
57 close OUT;
58 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
59 eval { binmode (\*TMP, ':raw') };
60 my $output;
61 {
62 local $/;
63 $output = <TMP>;
64 }
65 close TMP;
fe61459e 66 1 while unlink ('tmp.pod', 'out.tmp');
9f2f055a 67 my $expected = '';
68 while (<DATA>) {
69 last if $_ eq "###\n";
70 $expected .= $_;
71 }
fe61459e 72 is ($output, $expected, "Output correct for test $n");
9f2f055a 73 $n++;
74}
75
76# Below the marker are bits of POD and corresponding expected text output.
77# This is used to test specific features or problems with Pod::Text. The
78# input and output are separated by lines containing only ###.
79
80__DATA__
81
82###
83=head1 Test of SE<lt>E<gt>
84
85This is S<some whitespace>.
86###
87Test of S<>
88 This is some whitespace.
89
90###
91
92###
93=encoding utf-8
94
95=head1 I can eat glass
96
97=over 4
98
99=item Esperanto
100
101Mi povas manÄ\9di vitron, Ä\9di ne damaÄ\9das min.
102
103=item Braille
104
105â \8aâ \80â \89â \81â \9dâ \80â \91â \81â \9eâ \80â \9bâ \87â \81â \8eâ \8eâ \80â \81â \9dâ \99â \80â \8aâ \9eâ \80â \99â \95â \91â \8eâ \9dâ \9eâ \80â \93â ¥â \97â \9eâ \80â \8dâ \91
106
107=item Hindi
108
109मà¥\88à¤\82 à¤\95ाà¤\81à¤\9a à¤\96ा सà¤\95ता हà¥\82à¤\81 à¤\94र मà¥\81à¤\9dà¥\87 à¤\89ससà¥\87 à¤\95à¥\8bà¤\88 à¤\9aà¥\8bà¤\9f नहà¥\80à¤\82 पहà¥\81à¤\82à¤\9aतà¥\80.
110
111=back
112
113See L<http://www.columbia.edu/kermit/utf8.html>
114###
115I can eat glass
116 Esperanto
117 Mi povas manÄ\9di vitron, Ä\9di ne damaÄ\9das min.
118
119 Braille
120 â \8aâ \80â \89â \81â \9dâ \80â \91â \81â \9eâ \80â \9bâ \87â \81â \8eâ \8eâ \80â \81â \9dâ \99â \80â \8aâ \9eâ
121 \80â \99â \95â \91â \8eâ \9dâ \9eâ \80â \93â ¥â \97â \9eâ \80â \8dâ \91
122
123 Hindi
124 मà¥\88à¤\82 à¤\95ाà¤\81à¤\9a à¤\96ा सà¤\95ता हà¥\82à¤\81 à¤\94र
125 मà¥\81à¤\9dà¥\87 à¤\89ससà¥\87 à¤\95à¥\8bà¤\88 à¤\9aà¥\8bà¤\9f नहà¥\80à¤\82
126 पहà¥\81à¤\82à¤\9aतà¥\80.
127
128 See <http://www.columbia.edu/kermit/utf8.html>
129
130###
131
132###
133=head1 Beyoncé
134###
135Beyoncé
136###