xref: /openbsd-src/gnu/usr.bin/perl/cpan/podlators/t/man/iso-8859-1.t (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1#!/usr/bin/perl
2#
3# Test Pod::Man ISO-8859-1 handling
4#
5# Copyright 2016, 2019, 2022 Russ Allbery <rra@cpan.org>
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# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl
11
12use 5.008;
13use strict;
14use warnings;
15
16use lib 't/lib';
17
18use Test::More tests => 19;
19use Test::Podlators qw(test_snippet test_snippet_with_io);
20
21# Load the module.
22BEGIN {
23    use_ok('Pod::Man');
24}
25
26# Test the snippet with the old-school roff encoding.  Use _with_io to check
27# that we correctly add the accents preamble.
28test_snippet_with_io('Pod::Man', 'man/iso-8859-1-roff', { output => 'ascii' });
29
30# Test error handling when there are characters that cannot be represented in
31# the output character set.
32test_snippet('Pod::Man', 'man/iso-8859-1-error-die');
33test_snippet('Pod::Man', 'man/iso-8859-1-error-pod');
34
35# Force ISO 8859-1 on all relevant file handles.  Hide this in a string eval
36# so that older versions of Perl don't croak and minimum-version tests still
37# pass.
38#
39## no critic (BuiltinFunctions::ProhibitStringyEval)
40## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
41eval 'binmode(\*STDOUT, ":encoding(iso-8859-1)")';
42my $builder = Test::More->builder;
43eval 'binmode($builder->output, ":encoding(iso-8859-1)")';
44eval 'binmode($builder->failure_output, ":encoding(iso-8859-1)")';
45## use critic
46
47# Test the snippet with ISO 8859-1 output, with and without PerlIO layers.
48test_snippet_with_io(
49    'Pod::Man', 'man/iso-8859-1',
50    { encoding => 'iso-8859-1', output => 'iso-latin-1' },
51);
52test_snippet_with_io(
53    'Pod::Man', 'man/iso-8859-1',
54    { encoding => 'iso-8859-1', perlio_iso => 1, output => 'iso-latin-1' },
55);
56