7 unless (find PerlIO::Layer 'perlio') {
8 print "1..0 # Skip: not perlio\n";
11 if (exists $ENV{PERLIO} && $ENV{PERLIO} ne 'stdio') {
12 print "1..0 # PERLIO non-stdio\n";
22 skip("This perl does not have Encode", 43)
23 unless " $Config{extensions} " =~ / Encode /;
26 my ($result, $expected, $id) = @_;
27 my $n = scalar @$expected;
28 is($n, scalar @$expected, "$id layers = $n");
29 for (my $i = 0; $i < $n; $i++) {
30 my $j = $expected->[$i];
31 if (ref $j eq 'CODE') {
32 ok($j->($result->[$i]), "$id $i is ok");
35 sprintf("$id $i is %s", defined $j ? $j : "undef"));
40 check([ PerlIO::get_layers(STDIN) ],
44 open(F, ">:crlf", "afile");
46 check([ PerlIO::get_layers(F) ],
50 binmode(F, ":encoding(sjis)"); # "sjis" will be canonized to "shiftjis"
52 check([ PerlIO::get_layers(F) ],
53 [ qw[stdio crlf encoding(shiftjis) utf8] ],
58 check([ PerlIO::get_layers(F) ],
64 check([ PerlIO::get_layers(F) ],
70 check([ PerlIO::get_layers(F) ],
76 check([ PerlIO::get_layers(F) ],
80 binmode(F, ":encoding(utf8)");
82 check([ PerlIO::get_layers(F) ],
83 [ qw[stdio encoding(utf8) utf8] ],
86 binmode(F, ":raw :crlf");
88 check([ PerlIO::get_layers(F) ],
92 binmode(F, ":raw :encoding(latin1)"); # "latin1" will be canonized
94 check([ PerlIO::get_layers(F, details => 1) ],
95 [ "stdio", undef, sub { $_[0] > 0 },
96 "encoding", "iso-8859-1", sub { $_[0] & PerlIO::F_UTF8() } ],
97 ":raw:encoding(latin1)");
101 check([ PerlIO::get_layers(F) ],
108 use open(IN => ":crlf", OUT => ":encoding(cp1252)");
113 check([ PerlIO::get_layers(F, input => 1) ],
117 check([ PerlIO::get_layers(G, output => 1) ],
118 [ qw[stdio encoding(cp1252) utf8] ],
125 1 while unlink "afile";