7 unless (find PerlIO::Layer 'perlio') {
8 print "1..0 # Skip: not perlio\n";
17 my $NONSTDIO = exists $ENV{PERLIO} && $ENV{PERLIO} ne 'stdio';
20 skip("This perl does not have Encode", 43)
21 unless " $Config{extensions} " =~ / Encode /;
24 my ($result, $expected, $id) = @_;
25 my $n = scalar @$expected;
26 is($n, scalar @$expected, "$id - layers = $n");
28 # Get rid of "unix" and similar OS-specific low lever layer.
30 # Change expectations.
31 $expected->[0] = $ENV{PERLIO} if $expected->[0] eq "stdio";
33 for (my $i = 0; $i < $n; $i++) {
34 my $j = $expected->[$i];
35 if (ref $j eq 'CODE') {
36 ok($j->($result->[$i]), "$id - $i is ok");
39 sprintf("$id - $i is %s", defined $j ? $j : "undef"));
44 check([ PerlIO::get_layers(STDIN) ],
48 open(F, ">:crlf", "afile");
50 check([ PerlIO::get_layers(F) ],
54 binmode(F, ":encoding(sjis)"); # "sjis" will be canonized to "shiftjis"
56 check([ PerlIO::get_layers(F) ],
57 [ qw[stdio crlf encoding(shiftjis) utf8] ],
62 check([ PerlIO::get_layers(F) ],
68 check([ PerlIO::get_layers(F) ],
74 check([ PerlIO::get_layers(F) ],
80 check([ PerlIO::get_layers(F) ],
84 binmode(F, ":encoding(utf8)");
86 check([ PerlIO::get_layers(F) ],
87 [ qw[stdio encoding(utf8) utf8] ],
90 binmode(F, ":raw :crlf");
92 check([ PerlIO::get_layers(F) ],
96 binmode(F, ":raw :encoding(latin1)"); # "latin1" will be canonized
99 my @results = PerlIO::get_layers(F, details => 1);
101 # Get rid of "unix" and undef.
102 splice(@results, 0, 2) if $NONSTDIO;
105 [ "stdio", undef, sub { $_[0] > 0 },
106 "encoding", "iso-8859-1", sub { $_[0] & PerlIO::F_UTF8() } ],
107 ":raw:encoding(latin1)");
112 check([ PerlIO::get_layers(F) ],
119 use open(IN => ":crlf", OUT => ":encoding(cp1252)");
124 check([ PerlIO::get_layers(F, input => 1) ],
128 check([ PerlIO::get_layers(G, output => 1) ],
129 [ qw[stdio encoding(cp1252) utf8] ],
136 1 while unlink "afile";