3 # Tests for the command-line switches
8 unless (find PerlIO::Layer 'perlio') {
9 print "1..0 # Skip: not perlio\n";
21 END { unlink @tmpfiles }
23 my $b = pack("C*", unpack("U0C*", pack("U",256)));
25 $r = runperl( switches => [ '-CO', '-w' ],
26 prog => 'print chr(256)',
28 like( $r, qr/^$b(?:\r?\n)?$/s, '-CO: no warning on UTF-8 output' );
31 if (exists $ENV{PERL_UNICODE} &&
32 ($ENV{PERL_UNICODE} eq "" || $ENV{PERL_UNICODE} =~ /[SO]/)) {
33 skip(qq[cannot test with PERL_UNICODE locale "" or /[SO]/], 1);
35 $r = runperl( switches => [ '-CI', '-w' ],
36 prog => 'print ord(<STDIN>)',
39 like( $r, qr/^256(?:\r?\n)?$/s, '-CI: read in UTF-8 input' );
42 $r = runperl( switches => [ '-CE', '-w' ],
43 prog => 'warn chr(256), qq(\n)',
45 like( $r, qr/^$b(?:\r?\n)?$/s, '-CE: UTF-8 stderr' );
47 $r = runperl( switches => [ '-Co', '-w' ],
48 prog => 'open(F, q(>out)); print F chr(256); close F',
50 like( $r, qr/^$/s, '-Co: auto-UTF-8 open for output' );
52 push @tmpfiles, "out";
54 $r = runperl( switches => [ '-Ci', '-w' ],
55 prog => 'open(F, q(<out)); print ord(<F>); close F',
57 like( $r, qr/^256(?:\r?\n)?$/s, '-Ci: auto-UTF-8 open for input' );
59 $r = runperl( switches => [ '-CA', '-w' ],
60 prog => 'print ord shift',
62 args => [ chr(256) ] );
63 like( $r, qr/^256(?:\r?\n)?$/s, '-CA: @ARGV' );