source: trunk/essentials/dev-lang/perl/t/run/switchC.t

Last change on this file was 3181, checked in by bird, 18 years ago

perl 5.8.8

File size: 1.7 KB
Line 
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
23my $b = pack("C*", unpack("U0C*", pack("U",256)));
24
25$r = runperl( switches => [ '-CO', '-w' ],
26 prog => 'print chr(256)',
27 stderr => 1 );
28like( $r, qr/^$b(?:\r?\n)?$/s, '-CO: no warning on UTF-8 output' );
29
30SKIP: {
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);
34 }
35 $r = runperl( switches => [ '-CI', '-w' ],
36 prog => 'print ord(<STDIN>)',
37 stderr => 1,
38 stdin => $b );
39 like( $r, qr/^256(?:\r?\n)?$/s, '-CI: read in UTF-8 input' );
40}
41
42$r = runperl( switches => [ '-CE', '-w' ],
43 prog => 'warn chr(256), qq(\n)',
44 stderr => 1 );
45like( $r, qr/^$b(?:\r?\n)?$/s, '-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 );
50like( $r, qr/^$/s, '-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 );
57like( $r, qr/^256(?:\r?\n)?$/s, '-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) ] );
63like( $r, qr/^256(?:\r?\n)?$/s, '-CA: @ARGV' );
64
Note: See TracBrowser for help on using the repository browser.