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