This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Silence encoding.pm deprecation warnings in the core test suite
[perl5.git] / t / uni / chr.t
1 #!./perl -w
2
3 BEGIN {
4     require './test.pl';
5     skip_all_without_dynamic_extension('Encode');
6     skip_all("EBCDIC") if $::IS_EBCDIC;
7     skip_all_without_perlio();
8 }
9
10 use strict;
11 plan (tests => 8);
12 no warnings 'deprecated';
13 use encoding 'johab';
14
15 ok(chr(0x7f) eq "\x7f");
16 ok(chr(0x80) eq "\x80");
17 ok(chr(0xff) eq "\xff");
18
19 for my $i (127, 128, 255) {
20     ok(chr($i) eq pack('C', $i));
21 }
22
23 # [perl #83048]
24 {
25     my $w;
26     local $SIG{__WARN__} = sub { $w .= $_[0] };
27     my $chr = chr(-1);
28     is($chr, "\x{fffd}", "invalid values become REPLACEMENT CHARACTER");
29     like($w, qr/^Invalid negative number \(-1\) in chr at /, "with a warning");
30 }
31
32 __END__