14 skip("This perl does not have perlio and Encode", 43)
15 unless $Config{useperlio} && " $Config{extensions} " =~ / Encode /;
18 my ($result, $expected, $id) = @_;
19 my $n = scalar @$expected;
20 is($n, scalar @$expected, "$id layers = $n");
21 for (my $i = 0; $i < $n; $i++) {
22 my $j = $expected->[$i];
23 if (ref $j eq 'CODE') {
24 ok($j->($result->[$i]), "$id $i is ok");
27 sprintf("$id $i is %s", defined $j ? $j : "undef"));
32 check([ PerlIO::get_layers(STDIN) ],
36 open(F, ">:crlf", "afile");
38 check([ PerlIO::get_layers(F) ],
42 binmode(F, ":encoding(sjis)"); # "sjis" will be canonized to "shiftjis"
44 check([ PerlIO::get_layers(F) ],
45 [ qw[stdio crlf encoding(shiftjis) utf8] ],
50 check([ PerlIO::get_layers(F) ],
56 check([ PerlIO::get_layers(F) ],
62 check([ PerlIO::get_layers(F) ],
68 check([ PerlIO::get_layers(F) ],
72 binmode(F, ":encoding(utf8)");
74 check([ PerlIO::get_layers(F) ],
75 [ qw[stdio encoding(utf8) utf8] ],
78 binmode(F, ":raw :crlf");
80 check([ PerlIO::get_layers(F) ],
84 binmode(F, ":raw :encoding(latin1)"); # "latin1" will be canonized
86 check([ PerlIO::get_layers(F, details => 1) ],
87 [ "stdio", undef, sub { $_[0] > 0 },
88 "encoding", "iso-8859-1", sub { $_[0] & PerlIO::F_UTF8() } ],
89 ":raw:encoding(latin1)");
93 check([ PerlIO::get_layers(F) ],
100 use open(IN => ":crlf", OUT => ":encoding(cp1252)");
104 check([ PerlIO::get_layers(F, input => 1) ],
108 check([ PerlIO::get_layers(G, output => 1) ],
109 [ qw[stdio encoding(cp1252) utf8] ],
116 1 while unlink "afile";