1*0Sstevel@tonic-gate#!./perl -w 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate# Tests for the command-line switches 4*0Sstevel@tonic-gate 5*0Sstevel@tonic-gateBEGIN { 6*0Sstevel@tonic-gate chdir 't' if -d 't'; 7*0Sstevel@tonic-gate @INC = '../lib'; 8*0Sstevel@tonic-gate unless (find PerlIO::Layer 'perlio') { 9*0Sstevel@tonic-gate print "1..0 # Skip: not perlio\n"; 10*0Sstevel@tonic-gate exit 0; 11*0Sstevel@tonic-gate } 12*0Sstevel@tonic-gate} 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gaterequire "./test.pl"; 15*0Sstevel@tonic-gate 16*0Sstevel@tonic-gateplan(tests => 6); 17*0Sstevel@tonic-gate 18*0Sstevel@tonic-gatemy $r; 19*0Sstevel@tonic-gate 20*0Sstevel@tonic-gatemy @tmpfiles = (); 21*0Sstevel@tonic-gateEND { unlink @tmpfiles } 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gatemy $b = pack("C*", unpack("U0C*", pack("U",256))); 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate$r = runperl( switches => [ '-CO', '-w' ], 26*0Sstevel@tonic-gate prog => 'print chr(256)', 27*0Sstevel@tonic-gate stderr => 1 ); 28*0Sstevel@tonic-gatelike( $r, qr/^$b(?:\r?\n)?$/s, '-CO: no warning on UTF-8 output' ); 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gateSKIP: { 31*0Sstevel@tonic-gate if (exists $ENV{PERL_UNICODE} && 32*0Sstevel@tonic-gate ($ENV{PERL_UNICODE} eq "" || $ENV{PERL_UNICODE} =~ /[SO]/)) { 33*0Sstevel@tonic-gate skip(qq[cannot test with PERL_UNICODE locale "" or /[SO]/], 1); 34*0Sstevel@tonic-gate } 35*0Sstevel@tonic-gate $r = runperl( switches => [ '-CI', '-w' ], 36*0Sstevel@tonic-gate prog => 'print ord(<STDIN>)', 37*0Sstevel@tonic-gate stderr => 1, 38*0Sstevel@tonic-gate stdin => $b ); 39*0Sstevel@tonic-gate like( $r, qr/^256(?:\r?\n)?$/s, '-CI: read in UTF-8 input' ); 40*0Sstevel@tonic-gate} 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate$r = runperl( switches => [ '-CE', '-w' ], 43*0Sstevel@tonic-gate prog => 'warn chr(256), qq(\n)', 44*0Sstevel@tonic-gate stderr => 1 ); 45*0Sstevel@tonic-gatelike( $r, qr/^$b(?:\r?\n)?$/s, '-CE: UTF-8 stderr' ); 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate$r = runperl( switches => [ '-Co', '-w' ], 48*0Sstevel@tonic-gate prog => 'open(F, q(>out)); print F chr(256); close F', 49*0Sstevel@tonic-gate stderr => 1 ); 50*0Sstevel@tonic-gatelike( $r, qr/^$/s, '-Co: auto-UTF-8 open for output' ); 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gatepush @tmpfiles, "out"; 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate$r = runperl( switches => [ '-Ci', '-w' ], 55*0Sstevel@tonic-gate prog => 'open(F, q(<out)); print ord(<F>); close F', 56*0Sstevel@tonic-gate stderr => 1 ); 57*0Sstevel@tonic-gatelike( $r, qr/^256(?:\r?\n)?$/s, '-Ci: auto-UTF-8 open for input' ); 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate$r = runperl( switches => [ '-CA', '-w' ], 60*0Sstevel@tonic-gate prog => 'print ord shift', 61*0Sstevel@tonic-gate stderr => 1, 62*0Sstevel@tonic-gate args => [ chr(256) ] ); 63*0Sstevel@tonic-gatelike( $r, qr/^256(?:\r?\n)?$/s, '-CA: @ARGV' ); 64*0Sstevel@tonic-gate 65