Update all copyrights to 2003, from Jarkko
[p5sagit/p5-mst-13.2.git] / t / run / switchC.t
CommitLineData
76dd4efc 1#!./perl -w
2
3# Tests for the command-line switches
4
5BEGIN {
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
14require "./test.pl";
15
16plan(tests => 6);
17
18my $r;
19
20my @tmpfiles = ();
21END { unlink @tmpfiles }
22
23$r = runperl( switches => [ '-CO', '-w' ],
24 prog => 'print chr(256)',
25 stderr => 1 );
26is( $r, "\xC4\x80", '-CO: no warning on UTF-8 output' );
27
06e66572 28SKIP: {
29 for my $l (qw(LC_ALL LC_CTYPE LANG)) {
30 skip("cannot easily test under UTF-8 locale", 1)
31 if $ENV{$l} =~ /utf-?8/i;
32 }
33 $r = runperl( switches => [ '-CI', '-w' ],
34 prog => 'print ord(<STDIN>)',
35 stderr => 1,
36 verbose => 1,
37 stdin => "\xC4\x80" );
38 is( $r, 256, '-CI: read in UTF-8 input' );
39}
76dd4efc 40
41$r = runperl( switches => [ '-CE', '-w' ],
42 prog => 'warn chr(256), qq(\n)',
43 stderr => 1 );
44chomp $r;
45is( $r, "\xC4\x80", '-CE: UTF-8 stderr' );
46
47$r = runperl( switches => [ '-Co', '-w' ],
48 prog => 'open(F, q(>out)); print F chr(256); close F',
49 stderr => 1 );
50is( $r, '', '-Co: auto-UTF-8 open for output' );
51
52push @tmpfiles, "out";
53
54$r = runperl( switches => [ '-Ci', '-w' ],
55 prog => 'open(F, q(<out)); print ord(<F>); close F',
56 stderr => 1 );
57is( $r, 256, '-Ci: auto-UTF-8 open for input' );
58
59$r = runperl( switches => [ '-CA', '-w' ],
60 prog => 'print ord shift',
61 stderr => 1,
62 args => [ chr(256) ] );
63is( $r, 256, '-CA: @ARGV' );
64