summaryrefslogtreecommitdiff
path: root/dist/encoding-warnings/t/1-warning.t
blob: fa0bb6e4759d63502b34b35d72db7ce9a514496d (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
#!/usr/bin/perl
# $File: /member/local/autrijus/encoding-warnings//t/1-warning.t $ $Author: autrijus $
# $Revision: #5 $ $Change: 6145 $ $DateTime: 2004-07-16T03:49:06.717424Z $

BEGIN {
    if (ord("A") != 65) {
      print "1..0 # Skip: Encode not working on EBCDIC\n";
      exit 0;
    }
    unless (eval { require Encode } ) {
	print "1..0 # Skip: no Encode\n";
	exit 0;
    }
}

use Test;
use strict;

BEGIN {
    if ("$]" >= 5.025) {
	# Test the new almost-noop behaviour in new perls.
	plan tests => 3;
	my $w;
	$SIG{__WARN__} = sub { $w .= shift };
	require encoding::warnings;
	ok $w, undef, 'no warning from requiring encoding::warnings';
	ok(encoding::warnings->VERSION);
	encoding::warnings->import;
	ok $w, qr/^encoding::warnings is not supported /, 'import warning';
	exit;
    }
    # else continue with your usual scheduled testing...
    plan tests => 2;
}

use encoding::warnings;
ok(encoding::warnings->VERSION);

if ($] < 5.008) {
    ok(1);
    exit;
}

my ($a, $b, $c, $ok);

$SIG{__WARN__} = sub {
    if ($_[0] =~ /upgraded/) { ok(1); exit }
};

utf8::encode($a = chr(20000));
$b = chr(20000);
$c = $a . $b;

ok($ok);

__END__