Commit | Line | Data |
76dd4efc |
1 | #!./perl -w |
2 | |
3 | # Tests for the command-line switches |
4 | |
5 | BEGIN { |
6 | chdir 't' if -d 't'; |
7 | @INC = '../lib'; |
8 | unless (find PerlIO::Layer 'perlio') { |
9 | print "1..0 # Skip: not perlio\n"; |
10 | exit 0; |
11 | } |
12 | } |
13 | |
14 | require "./test.pl"; |
15 | |
16 | plan(tests => 6); |
17 | |
18 | my $r; |
19 | |
20 | my @tmpfiles = (); |
21 | END { unlink @tmpfiles } |
22 | |
23 | $r = runperl( switches => [ '-CO', '-w' ], |
24 | prog => 'print chr(256)', |
25 | stderr => 1 ); |
26 | is( $r, "\xC4\x80", '-CO: no warning on UTF-8 output' ); |
27 | |
06e66572 |
28 | SKIP: { |
81ff9b36 |
29 | if (exists $ENV{PERL_UNICODE} && |
30 | ($ENV{PERL_UNICODE} eq "" || $ENV{PERL_UNICODE} =~ /[SO]/)) { |
31 | skip(qq[cannot test with PERL_UNICODE locale "" or /[SO]/], 1); |
06e66572 |
32 | } |
33 | $r = runperl( switches => [ '-CI', '-w' ], |
34 | prog => 'print ord(<STDIN>)', |
35 | stderr => 1, |
06e66572 |
36 | stdin => "\xC4\x80" ); |
37 | is( $r, 256, '-CI: read in UTF-8 input' ); |
38 | } |
76dd4efc |
39 | |
40 | $r = runperl( switches => [ '-CE', '-w' ], |
41 | prog => 'warn chr(256), qq(\n)', |
42 | stderr => 1 ); |
43 | chomp $r; |
44 | is( $r, "\xC4\x80", '-CE: UTF-8 stderr' ); |
45 | |
46 | $r = runperl( switches => [ '-Co', '-w' ], |
47 | prog => 'open(F, q(>out)); print F chr(256); close F', |
48 | stderr => 1 ); |
49 | is( $r, '', '-Co: auto-UTF-8 open for output' ); |
50 | |
51 | push @tmpfiles, "out"; |
52 | |
53 | $r = runperl( switches => [ '-Ci', '-w' ], |
54 | prog => 'open(F, q(<out)); print ord(<F>); close F', |
55 | stderr => 1 ); |
56 | is( $r, 256, '-Ci: auto-UTF-8 open for input' ); |
57 | |
58 | $r = runperl( switches => [ '-CA', '-w' ], |
59 | prog => 'print ord shift', |
60 | stderr => 1, |
61 | args => [ chr(256) ] ); |
62 | is( $r, 256, '-CA: @ARGV' ); |
63 | |