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 | |
28 | $r = runperl( switches => [ '-CI', '-w' ], |
29 | prog => 'print ord(<STDIN>)', |
30 | stderr => 1, |
31 | stdin => chr(256) ); |
32 | is( $r, 256, '-CI: read in UTF-8 output' ); |
33 | |
34 | $r = runperl( switches => [ '-CE', '-w' ], |
35 | prog => 'warn chr(256), qq(\n)', |
36 | stderr => 1 ); |
37 | chomp $r; |
38 | is( $r, "\xC4\x80", '-CE: UTF-8 stderr' ); |
39 | |
40 | $r = runperl( switches => [ '-Co', '-w' ], |
41 | prog => 'open(F, q(>out)); print F chr(256); close F', |
42 | stderr => 1 ); |
43 | is( $r, '', '-Co: auto-UTF-8 open for output' ); |
44 | |
45 | push @tmpfiles, "out"; |
46 | |
47 | $r = runperl( switches => [ '-Ci', '-w' ], |
48 | prog => 'open(F, q(<out)); print ord(<F>); close F', |
49 | stderr => 1 ); |
50 | is( $r, 256, '-Ci: auto-UTF-8 open for input' ); |
51 | |
52 | $r = runperl( switches => [ '-CA', '-w' ], |
53 | prog => 'print ord shift', |
54 | stderr => 1, |
55 | args => [ chr(256) ] ); |
56 | is( $r, 256, '-CA: @ARGV' ); |
57 | |