From: Jarkko Hietaniemi Date: Tue, 25 Feb 2003 18:20:01 +0000 (+0000) Subject: Add tests for the -C switch. Depending on the X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=76dd4efc0032d8cf72bade55b190df61909f479d;p=p5sagit%2Fp5-mst-13.2.git Add tests for the -C switch. Depending on the CLIs some $^O dance may be needed. p4raw-id: //depot/perl@18779 --- diff --git a/MANIFEST b/MANIFEST index 7ff5b2f..341365f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2697,6 +2697,7 @@ t/run/fresh_perl.t Tests that require a fresh perl. t/run/noswitch.t Test aliasing ARGV for other switch tests t/run/runenv.t Test if perl honors its environment variables. t/run/switcha.t Test the -a switch +t/run/switchC.t Test the -C switch t/run/switches.t Tests for the other switches t/run/switchF.t Test the -F switch t/run/switchI.t Test the -I switch diff --git a/t/run/switchC.t b/t/run/switchC.t new file mode 100644 index 0000000..9283fa8 --- /dev/null +++ b/t/run/switchC.t @@ -0,0 +1,57 @@ +#!./perl -w + +# Tests for the command-line switches + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + unless (find PerlIO::Layer 'perlio') { + print "1..0 # Skip: not perlio\n"; + exit 0; + } +} + +require "./test.pl"; + +plan(tests => 6); + +my $r; + +my @tmpfiles = (); +END { unlink @tmpfiles } + +$r = runperl( switches => [ '-CO', '-w' ], + prog => 'print chr(256)', + stderr => 1 ); +is( $r, "\xC4\x80", '-CO: no warning on UTF-8 output' ); + +$r = runperl( switches => [ '-CI', '-w' ], + prog => 'print ord()', + stderr => 1, + stdin => chr(256) ); +is( $r, 256, '-CI: read in UTF-8 output' ); + +$r = runperl( switches => [ '-CE', '-w' ], + prog => 'warn chr(256), qq(\n)', + stderr => 1 ); +chomp $r; +is( $r, "\xC4\x80", '-CE: UTF-8 stderr' ); + +$r = runperl( switches => [ '-Co', '-w' ], + prog => 'open(F, q(>out)); print F chr(256); close F', + stderr => 1 ); +is( $r, '', '-Co: auto-UTF-8 open for output' ); + +push @tmpfiles, "out"; + +$r = runperl( switches => [ '-Ci', '-w' ], + prog => 'open(F, q(); close F', + stderr => 1 ); +is( $r, 256, '-Ci: auto-UTF-8 open for input' ); + +$r = runperl( switches => [ '-CA', '-w' ], + prog => 'print ord shift', + stderr => 1, + args => [ chr(256) ] ); +is( $r, 256, '-CA: @ARGV' ); +