$! and $1 are PVMG(), but their content is undefined when peeking
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / text-utf8.t
CommitLineData
bc9c7511 1#!/usr/bin/perl -w
2#
3# text-utf8.t -- Test Pod::Text with UTF-8 input.
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
10BEGIN {
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..3\n";
20}
21
22END {
23 print "not ok 1\n" unless $loaded;
24}
25
26use Pod::Text;
27use Pod::Simple;
28
29$loaded = 1;
30print "ok 1\n";
31
32my $parser = Pod::Text->new or die "Cannot create parser\n";
33my $n = 2;
34eval { binmode (\*DATA, ':encoding(utf-8)') };
35eval { binmode (\*STDOUT, ':encoding(utf-8)') };
36while (<DATA>) {
37 next until $_ eq "###\n";
38 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
39 eval { binmode (\*TMP, ':encoding(utf-8)') };
40 print TMP "=encoding UTF-8\n\n";
41 while (<DATA>) {
42 last if $_ eq "###\n";
43 print TMP $_;
44 }
45 close TMP;
46 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
47 eval { binmode (\*OUT, ':encoding(utf-8)') };
48 $parser->parse_from_file ('tmp.pod', \*OUT);
49 close OUT;
50 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
51 eval { binmode (\*TMP, ':encoding(utf-8)') };
52 my $output;
53 {
54 local $/;
55 $output = <TMP>;
56 }
57 close TMP;
58 unlink ('tmp.pod', 'out.tmp');
59 my $expected = '';
60 while (<DATA>) {
61 last if $_ eq "###\n";
62 $expected .= $_;
63 }
64 if ($output eq $expected) {
65 print "ok $n\n";
66 } else {
67 print "not ok $n\n";
68 print "Expected\n========\n$expected\nOutput\n======\n$output\n";
69 }
70 $n++;
71}
72
73# Below the marker are bits of POD and corresponding expected text output.
74# This is used to test specific features or problems with Pod::Text. The
75# input and output are separated by lines containing only ###.
76
77__DATA__
78
79###
80=head1 Test of SE<lt>E<gt>
81
82This is S<some whitespace>.
83###
84Test of S<>
85 This is some whitespace.
86
87###
88
89###
90=head1 I can eat glass
91
92=over 4
93
94=item Esperanto
95
96Mi povas manĝi vitron, ĝi ne damaĝas min.
97
98=item Braille
99
100⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑
101
102=item Hindi
103
104मैं काँच खा सकता हूँ और मुझे उससे कोई चोट नहीं पहुंचती.
105
106=back
107
108See L<http://www.columbia.edu/kermit/utf8.html>
109###
110I can eat glass
111 Esperanto
112 Mi povas manĝi vitron, ĝi ne damaĝas min.
113
114 Braille
115 ⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑
116
117 Hindi
118 मैं काँच खा सकता हूँ और मुझे उससे कोई चोट नहीं पहुंचती.
119
120 See <http://www.columbia.edu/kermit/utf8.html>
121
122###