BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
- push @INC, "::lib:$MacPerl::Architecture:" if $^O eq 'MacOS';
require Config; import Config;
+ require './test.pl';
}
-use Test::More tests => 22;
+plan 23;
# open::import expects 'open' as its first argument, but it clashes with open()
sub import {
is( $^H{'open_IO'}, 'crlf', 'should record last layer set in %^H' );
SKIP: {
- skip("no perlio, no :utf8", 4) unless (find PerlIO::Layer 'perlio');
+ skip("no perlio, no :utf8", 12) unless (find PerlIO::Layer 'perlio');
eval <<EOE;
use open ':utf8';
"checking syswrite() output on :utf8 streams by reading it back in");
}
}
-
SKIP: {
- skip("no perlio", 1) unless (find PerlIO::Layer 'perlio');
- use open IN => ':non-existent';
- eval {
- require Symbol; # Anything that exists but we havn't loaded
- };
- like($@, qr/Can't locate Symbol|Recursive call/i,
- "test for an endless loop in PerlIO_find_layer");
+ skip("no perlio", 2) unless (find PerlIO::Layer 'perlio');
+ skip("no Encode", 2) unless $Config{extensions} =~ m{\bEncode\b};
+
+ eval q[use Encode::Alias;use open ":std", ":locale"];
+ is($@, '', 'can use :std and :locale');
+}
+
+{
+ local $ENV{PERL_UNICODE};
+ delete $ENV{PERL_UNICODE};
+ is runperl(
+ progs => [
+ 'use open q\:encoding(UTF-8)\, q-:std-;',
+ 'use open q\:encoding(UTF-8)\;',
+ 'if(($_ = <STDIN>) eq qq-\x{100}\n-) { print qq-stdin ok\n- }',
+ 'else { print qq-got -, join(q q q, map ord, split//), "\n" }',
+ 'print STDOUT qq-\x{ff}\n-;',
+ 'print STDERR qq-\x{ff}\n-;',
+ ],
+ stdin => "\xc4\x80\n",
+ stderr => 1,
+ ),
+ "stdin ok\n\xc3\xbf\n\xc3\xbf\n",
+ "use open without :std does not affect standard handles",
+ ;
}
END {