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