7 unless (find PerlIO::Layer 'perlio') {
8 print "1..0 # Skip: not perlio\n";
18 skip("This perl does not have Encode", 43)
19 unless " $Config{extensions} " =~ / Encode /;
22 my ($result, $expected, $id) = @_;
23 my $n = scalar @$expected;
24 is($n, scalar @$expected, "$id - layers = $n");
26 # Get rid of "unix" and similar OS-specific low lever layer.
28 # Change expectations.
29 $expected->[0] = "perlio" if $expected->[0] eq "stdio";
31 for (my $i = 0; $i < $n; $i++) {
32 my $j = $expected->[$i];
33 if (ref $j eq 'CODE') {
34 ok($j->($result->[$i]), "$id - $i is ok");
37 sprintf("$id - $i is %s", defined $j ? $j : "undef"));
42 check([ PerlIO::get_layers(STDIN) ],
46 open(F, ">:crlf", "afile");
48 check([ PerlIO::get_layers(F) ],
52 binmode(F, ":encoding(sjis)"); # "sjis" will be canonized to "shiftjis"
54 check([ PerlIO::get_layers(F) ],
55 [ qw[stdio crlf encoding(shiftjis) utf8] ],
60 check([ PerlIO::get_layers(F) ],
66 check([ PerlIO::get_layers(F) ],
72 check([ PerlIO::get_layers(F) ],
78 check([ PerlIO::get_layers(F) ],
82 binmode(F, ":encoding(utf8)");
84 check([ PerlIO::get_layers(F) ],
85 [ qw[stdio encoding(utf8) utf8] ],
88 binmode(F, ":raw :crlf");
90 check([ PerlIO::get_layers(F) ],
94 binmode(F, ":raw :encoding(latin1)"); # "latin1" will be canonized
97 my @results = PerlIO::get_layers(F, details => 1);
99 # Get rid of "unix" and undef.
100 splice(@results, 0, 2) if $ENV{PERLIO};
103 [ "stdio", undef, sub { $_[0] > 0 },
104 "encoding", "iso-8859-1", sub { $_[0] & PerlIO::F_UTF8() } ],
105 ":raw:encoding(latin1)");
110 check([ PerlIO::get_layers(F) ],
117 use open(IN => ":crlf", OUT => ":encoding(cp1252)");
122 check([ PerlIO::get_layers(F, input => 1) ],
126 check([ PerlIO::get_layers(G, output => 1) ],
127 [ qw[stdio encoding(cp1252) utf8] ],
134 1 while unlink "afile";