xref: /openbsd-src/gnu/usr.bin/perl/cpan/podlators/t/man/iso-8859-1.t (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
15759b3d2Safresh1#!/usr/bin/perl
25759b3d2Safresh1#
35759b3d2Safresh1# Test Pod::Man ISO-8859-1 handling
45759b3d2Safresh1#
5*f2a19305Safresh1# Copyright 2016, 2019, 2022 Russ Allbery <rra@cpan.org>
65759b3d2Safresh1#
75759b3d2Safresh1# This program is free software; you may redistribute it and/or modify it
85759b3d2Safresh1# under the same terms as Perl itself.
9de8cc8edSafresh1#
10de8cc8edSafresh1# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl
115759b3d2Safresh1
12de8cc8edSafresh1use 5.008;
135759b3d2Safresh1use strict;
145759b3d2Safresh1use warnings;
155759b3d2Safresh1
165759b3d2Safresh1use lib 't/lib';
175759b3d2Safresh1
18*f2a19305Safresh1use Test::More tests => 19;
19*f2a19305Safresh1use Test::Podlators qw(test_snippet test_snippet_with_io);
205759b3d2Safresh1
215759b3d2Safresh1# Load the module.
225759b3d2Safresh1BEGIN {
235759b3d2Safresh1    use_ok('Pod::Man');
245759b3d2Safresh1}
255759b3d2Safresh1
26*f2a19305Safresh1# Test the snippet with the old-school roff encoding.  Use _with_io to check
27*f2a19305Safresh1# that we correctly add the accents preamble.
28*f2a19305Safresh1test_snippet_with_io('Pod::Man', 'man/iso-8859-1-roff', { output => 'ascii' });
29*f2a19305Safresh1
30*f2a19305Safresh1# Test error handling when there are characters that cannot be represented in
31*f2a19305Safresh1# the output character set.
32*f2a19305Safresh1test_snippet('Pod::Man', 'man/iso-8859-1-error-die');
33*f2a19305Safresh1test_snippet('Pod::Man', 'man/iso-8859-1-error-pod');
34*f2a19305Safresh1
35*f2a19305Safresh1# Force ISO 8859-1 on all relevant file handles.  Hide this in a string eval
36*f2a19305Safresh1# so that older versions of Perl don't croak and minimum-version tests still
37*f2a19305Safresh1# pass.
38*f2a19305Safresh1#
39*f2a19305Safresh1## no critic (BuiltinFunctions::ProhibitStringyEval)
40*f2a19305Safresh1## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
41*f2a19305Safresh1eval 'binmode(\*STDOUT, ":encoding(iso-8859-1)")';
42*f2a19305Safresh1my $builder = Test::More->builder;
43*f2a19305Safresh1eval 'binmode($builder->output, ":encoding(iso-8859-1)")';
44*f2a19305Safresh1eval 'binmode($builder->failure_output, ":encoding(iso-8859-1)")';
45*f2a19305Safresh1## use critic
46*f2a19305Safresh1
47*f2a19305Safresh1# Test the snippet with ISO 8859-1 output, with and without PerlIO layers.
48*f2a19305Safresh1test_snippet_with_io(
49*f2a19305Safresh1    'Pod::Man', 'man/iso-8859-1',
50*f2a19305Safresh1    { encoding => 'iso-8859-1', output => 'iso-latin-1' },
51*f2a19305Safresh1);
52*f2a19305Safresh1test_snippet_with_io(
53*f2a19305Safresh1    'Pod::Man', 'man/iso-8859-1',
54*f2a19305Safresh1    { encoding => 'iso-8859-1', perlio_iso => 1, output => 'iso-latin-1' },
55*f2a19305Safresh1);
56