xref: /openbsd-src/gnu/usr.bin/perl/dist/encoding-warnings/t/1-warning.t (revision e068048151d29f2562a32185e21a8ba885482260)
1#!/usr/bin/perl
2# $File: /member/local/autrijus/encoding-warnings//t/1-warning.t $ $Author: autrijus $
3# $Revision: #5 $ $Change: 6145 $ $DateTime: 2004-07-16T03:49:06.717424Z $
4
5BEGIN {
6    if (ord("A") != 65) {
7        print "1..0 # Skip: Encode not working on EBCDIC\n";
8        exit 0;
9    }
10    unless (eval { require Encode } ) {
11        print "1..0 # Skip: no Encode\n";
12        exit 0;
13    }
14}
15
16use strict;
17use warnings;
18use Test::More;
19
20BEGIN {
21    if ("$]" >= 5.025) {
22        # Test the new almost-noop behaviour in new perls.
23        plan tests => 3;
24        my $w;
25        $SIG{__WARN__} = sub { $w .= shift };
26        require encoding::warnings;
27        is $w, undef, 'no warning from requiring encoding::warnings';
28        ok(encoding::warnings->VERSION);
29        encoding::warnings->import;
30        like $w, qr/^encoding::warnings is not supported /, 'import warning';
31        exit;
32    }
33    # else continue with your usual scheduled testing...
34    plan tests => 2;
35}
36
37use encoding::warnings;
38ok(encoding::warnings->VERSION);
39
40if ($] < 5.008) {
41    ok(1);
42    exit;
43}
44
45my ($a, $b, $c, $ok);
46
47$SIG{__WARN__} = sub {
48    if ($_[0] =~ /upgraded/) { ok(1); exit }
49};
50
51utf8::encode($a = chr(20000));
52$b = chr(20000);
53$c = $a . $b;
54
55ok($ok);
56
57__END__
58