Actually note that Shell.pm is deprecated for 5.13 and 5.14, so we can
[p5sagit/p5-mst-13.2.git] / cpan / podlators / t / man-utf8.t
CommitLineData
2504ae52 1#!/usr/bin/perl -w
2#
3# man-options.t -- Additional tests for Pod::Man options.
4#
fe61459e 5# Copyright 2002, 2004, 2006, 2008, 2009 Russ Allbery <rra@stanford.edu>
2504ae52 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';
2504ae52 14 }
15 unshift (@INC, '../blib/lib');
16 $| = 1;
2504ae52 17}
18
fe61459e 19use strict;
2504ae52 20
fe61459e 21use Test::More;
2504ae52 22
fe61459e 23# UTF-8 support requires Perl 5.8 or later.
24BEGIN {
25 if ($] < 5.008) {
26 plan skip_all => 'Perl 5.8 required for UTF-8 support';
27 } else {
28 plan tests => 7;
29 }
30}
31BEGIN { use_ok ('Pod::Man') }
2504ae52 32
fe61459e 33# Force UTF-8 on all relevant file handles. Do this inside eval in case the
34# encoding parameter doesn't work.
2504ae52 35eval { binmode (\*DATA, ':encoding(utf-8)') };
9f2f055a 36eval { binmode (\*STDOUT, ':encoding(utf-8)') };
fe61459e 37my $builder = Test::More->builder;
38eval { binmode ($builder->output, ':encoding(utf-8)') };
39eval { binmode ($builder->failure_output, ':encoding(utf-8)') };
40
41my $n = 1;
2504ae52 42while (<DATA>) {
43 my %options;
44 next until $_ eq "###\n";
45 while (<DATA>) {
46 last if $_ eq "###\n";
47 my ($option, $value) = split;
48 $options{$option} = $value;
49 }
50 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
51 eval { binmode (\*TMP, ':encoding(utf-8)') };
52 print TMP "=encoding utf-8\n\n";
53 while (<DATA>) {
54 last if $_ eq "###\n";
55 print TMP $_;
56 }
57 close TMP;
fe61459e 58 my $parser = Pod::Man->new (%options);
59 isa_ok ($parser, 'Pod::Man', 'Parser object');
2504ae52 60 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
2504ae52 61 $parser->parse_from_file ('tmp.pod', \*OUT);
62 close OUT;
63 my $accents = 0;
64 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
65 eval { binmode (\*TMP, ':encoding(utf-8)') };
66 while (<TMP>) {
67 $accents = 1 if /Accent mark definitions/;
68 last if /^\.nh/;
69 }
70 my $output;
71 {
72 local $/;
73 $output = <TMP>;
74 }
75 close TMP;
fe61459e 76 1 while unlink ('tmp.pod', 'out.tmp');
77 if ($options{utf8}) {
78 ok (!$accents, "Saw no accent definitions for test $n");
2504ae52 79 } else {
fe61459e 80 ok ($accents, "Saw accent definitions for test $n");
2504ae52 81 }
2504ae52 82 my $expected = '';
83 while (<DATA>) {
84 last if $_ eq "###\n";
85 $expected .= $_;
86 }
fe61459e 87 is ($output, $expected, "Output correct for test $n");
2504ae52 88 $n++;
89}
90
91# Below the marker are bits of POD and corresponding expected text output.
92# This is used to test specific features or problems with Pod::Man. The
93# input and output are separated by lines containing only ###.
94
95__DATA__
96
97###
98utf8 1
99###
100=head1 BEYONCÉ
101
102Beyoncé! Beyoncé! Beyoncé!!
103
104 Beyoncé! Beyoncé!
105 Beyoncé! Beyoncé!
106 Beyoncé! Beyoncé!
107
108Older versions did not convert Beyoncé in verbatim.
109###
110.SH "BEYONCÉ"
111.IX Header "BEYONCÉ"
112Beyoncé! Beyoncé! Beyoncé!!
113.PP
114.Vb 3
115\& Beyoncé! Beyoncé!
116\& Beyoncé! Beyoncé!
117\& Beyoncé! Beyoncé!
118.Ve
119.PP
120Older versions did not convert Beyoncé in verbatim.
121###
122
123###
124utf8 1
125###
126=head1 SE<lt>E<gt> output with UTF-8
127
128This is S<non-breaking output>.
129###
130.SH "S<> output with UTF\-8"
131.IX Header "S<> output with UTF-8"
132This is non-breaking output.
133###