xref: /openbsd-src/gnu/usr.bin/perl/dist/encoding-warnings/t/4-lexical.t (revision e068048151d29f2562a32185e21a8ba885482260)
1use strict;
2use warnings;
3BEGIN {
4    if ("$]" >= 5.025) {
5        print "1..0 # Skip: encoding::warnings not supported on perl 5.26\n";
6        exit 0;
7    }
8    if (ord("A") != 65) {
9        print "1..0 # Skip: Encode not working on EBCDIC\n";
10        exit 0;
11    }
12    use Config;
13    if ($Config::Config{'extensions'} !~ /\bEncode\b/) {
14        print "1..0 # Skip: Encode was not built\n";
15        exit 0;
16    }
17
18}
19
20use Test::More tests => 3;
21
22{
23    use encoding::warnings;
24    ok(encoding::warnings->VERSION);
25
26    if ($] < 5.009004) {
27        ok('skipped');
28        ok('skipped');
29        exit;
30    }
31
32    my ($a, $b, $c, $warned);
33
34    local $SIG{__WARN__} = sub {
35        if ($_[0] =~ /upgraded/) { $warned = 1 }
36    };
37
38    utf8::encode($a = chr(20000));
39    $b = chr(20000);
40    $c = $a . $b;
41    ok($warned);
42}
43
44{
45    my ($a, $b, $c, $warned);
46
47    local $SIG{__WARN__} = sub {
48        if ($_[0] =~ /upgraded/) { $warned = 1 }
49    };
50
51    utf8::encode($a = chr(20000));
52    $b = chr(20000);
53    $c = $a . $b;
54    ok(!$warned);
55}
56
57
58__END__
59