summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/t/Legacy/utf8.t
blob: 97e4cf4c4a978df3e3df0bc4c6a27e9f5d85f893 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl -w
# HARNESS-NO-STREAM
# HARNESS-NO-PRELOAD

BEGIN {
    if( $ENV{PERL_CORE} ) {
        chdir 't';
        @INC = '../lib';
    }
}

use strict;
use warnings;

my $have_perlio;
BEGIN {
    # All together so Test::More sees the open discipline
    $have_perlio = eval q[
        require PerlIO;
        binmode *STDOUT, ":encoding(utf8)";
        binmode *STDERR, ":encoding(utf8)";
        require Test::More;
        1;
    ];
}

use Test::More;
unless (Test::Builder->new->{Stack}->top->format->isa('Test::Builder::Formatter')) {
    plan skip_all => 'Test cannot be run using this formatter';
}

if( !$have_perlio ) {
    plan skip_all => "Don't have PerlIO";
}
else {
    plan tests => 5;
}

SKIP: {
    skip( "Need PerlIO for this feature", 3 )
        unless $have_perlio;

    my %handles = (
        output          => \*STDOUT,
        failure_output  => \*STDERR,
        todo_output     => \*STDOUT
    );

    for my $method (keys %handles) {
        my $src = $handles{$method};

        my $dest = Test::More->builder->$method;

        is_deeply { map { $_ => 1 } PerlIO::get_layers($dest) },
                  { map { $_ => 1 } PerlIO::get_layers($src)  },
                  "layers copied to $method";
    }
}


# Test utf8 is ok.
{
    my $uni = "\x{11e}";

    my @warnings;
    local $SIG{__WARN__} = sub {
        push @warnings, @_;
    };

    is( $uni, $uni, "Testing $uni" );
    is_deeply( \@warnings, [] );
}