#!./perl
BEGIN {
chdir 't' if -d 't';
}
# open::import expects 'open' as its first argument, but it clashes with open()
}
# can't use require_ok() here, with a name like 'open'
# this should fail
'import should fail without args' );
# the hint bits shouldn't be set yet
'hint bits should not be set in $^H before open import' );
# prevent it from loading I18N::Langinfo, so we can test encoding failures
my $warn;
$warn .= shift;
};
# and it shouldn't be able to find this layer
'should not warn about unknown layer with bad layer provided' );
'should warn about unknown layer with bad layer provided' );
SKIP: {
# now load a real-looking locale
'should set a valid locale layer' );
}
# and see if it sets the magic variables appropriately
'hint bits should be set in $^H after open import' );
# it should reset them appropriately, too
# it dies if you don't set IN, OUT, or IO
# but it handles them all so well together
'should set multi types, multi layer' );
SKIP: {
eval <<EOE;
use open ':utf8';
open(O, ">utf8");
print O chr(0x100);
close O;
open(I, "<utf8");
is(ord(<I>), 0x100, ":utf8 single wide character round-trip");
close I;
EOE
print F @a;
close F;
sub systell {
}
require bytes; # not use
my $ok;
$ok = $a = 0;
for (@a) {
unless (
) {
print '# $a == ', $a, "\n";
print '# $c == ', $c, "\n";
last;
}
$ok++;
}
close F;
"on :utf8 streams sysread() should work on characters, not bytes");
# syswrite() on should work on characters, not bytes
$ok = $a = 0;
for (@a) {
unless (
) {
print '# $a == ', $a, "\n";
print '# $c == ', $c, "\n";
print "not ";
last;
}
$ok++;
}
close G;
"on :utf8 streams syswrite() should work on characters, not bytes");
$ok = $a = 0;
for (@a) {
unless (
) {
print '# $a == ', $a, "\n";
print '# $c == ', $c, "\n";
last;
}
$ok++;
}
close G;
"checking syswrite() output on :utf8 streams by reading it back in");
}
SKIP: {
eval {
require Symbol; # Anything that exists but we havn't loaded
};
"test for an endless loop in PerlIO_find_layer");
}
END {
1 while unlink "utf8";
1 while unlink "a";
1 while unlink "b";
}
# the test cases beyond __DATA__ need to be executed separately
__DATA__
eval { open::_get_locale_encoding() };
%%%
# the special :locale layer
# the :locale will probe the locale environment variables like LANG
open(O, ">koi8");
print O chr(0x430); # Unicode CYRILLIC SMALL LETTER A = KOI8-R 0xc1
close O;
open(I, "<koi8");
printf "%#x\n", ord(<I>), "\n"; # this should print 0xc1
close I;
%%%