xref: /openbsd-src/gnu/usr.bin/perl/cpan/podlators/t/text/iso-8859-1.t (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1#!/usr/bin/perl
2#
3# Test Pod::Text 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 => 13;
19use Test::Podlators qw(test_snippet test_snippet_with_io);
20
21# Load the module.
22BEGIN {
23    use_ok('Pod::Text');
24}
25
26# Test the snippet with the proper encoding.
27test_snippet('Pod::Text', 'text/iso-8859-1', { encoding => 'iso-8859-1' });
28
29# Test error handling when there are characters that cannot be represented in
30# the output character set.
31test_snippet('Pod::Text', 'text/iso-8859-1-error-die');
32test_snippet('Pod::Text', 'text/iso-8859-1-error-pod');
33
34# Force ISO 8859-1 on all relevant file handles.  Hide this in a string eval
35# so that older versions of Perl don't croak and minimum-version tests still
36# pass.
37#
38## no critic (BuiltinFunctions::ProhibitStringyEval)
39## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
40eval 'binmode(\*STDOUT, ":encoding(iso-8859-1)")';
41my $builder = Test::More->builder;
42eval 'binmode($builder->output, ":encoding(iso-8859-1)")';
43eval 'binmode($builder->failure_output, ":encoding(iso-8859-1)")';
44## use critic
45
46# Test the snippet with ISO 8859-1 output with a PerlIO layer.
47test_snippet_with_io(
48    'Pod::Text', 'text/iso-8859-1',
49    { encoding => 'iso-8859-1', output => 'iso-8859-1', perlio_iso => 1 },
50);
51
52# Test the snippet with ISO 8859-1 input but an encoding forcing output to
53# UTF-8.
54test_snippet('Pod::Text', 'text/iso-8859-1-utf8');
55