1#!/usr/bin/perl
2#
3# Test Pod::Man UTF-8 handling, with and without PerlIO.
4#
5# Copyright 2002, 2004, 2006, 2008-2010, 2012, 2014-2015, 2018-2020
6#     Russ Allbery <rra@cpan.org>
7#
8# This program is free software; you may redistribute it and/or modify it
9# under the same terms as Perl itself.
10#
11# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl
12
13use 5.008;
14use strict;
15use warnings;
16
17use lib 't/lib';
18
19use Test::More tests => 13;
20use Test::Podlators qw(test_snippet_with_io);
21
22# Load the module.
23BEGIN {
24    use_ok('Pod::Man');
25}
26
27# Force UTF-8 on all relevant file handles.  Hide this in a string eval so
28# that older versions of Perl don't croak and minimum-version tests still
29# pass.
30#
31## no critic (BuiltinFunctions::ProhibitStringyEval)
32## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
33eval 'binmode(\*STDOUT, ":encoding(utf-8)")';
34my $builder = Test::More->builder;
35eval 'binmode($builder->output, ":encoding(utf-8)")';
36eval 'binmode($builder->failure_output, ":encoding(utf-8)")';
37## use critic
38
39# For each of the UTF-8 snippets, check them with and without PerlIO layers.
40for my $snippet (qw(utf8-nonbreaking utf8-verbatim)) {
41    test_snippet_with_io('Pod::Man', "man/$snippet");
42    test_snippet_with_io('Pod::Man', "man/$snippet", { perlio_utf8 => 1 });
43}
44