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");
25 for (my $i = 0; $i < $n; $i++) {
26 my $j = $expected->[$i];
27 if (ref $j eq 'CODE') {
28 ok($j->($result->[$i]), "$id $i is ok");
31 sprintf("$id $i is %s", defined $j ? $j : "undef"));
36 check([ PerlIO::get_layers(STDIN) ],
40 open(F, ">:crlf", "afile");
42 check([ PerlIO::get_layers(F) ],
46 binmode(F, ":encoding(sjis)"); # "sjis" will be canonized to "shiftjis"
48 check([ PerlIO::get_layers(F) ],
49 [ qw[stdio crlf encoding(shiftjis) utf8] ],
54 check([ PerlIO::get_layers(F) ],
60 check([ PerlIO::get_layers(F) ],
66 check([ PerlIO::get_layers(F) ],
72 check([ PerlIO::get_layers(F) ],
76 binmode(F, ":encoding(utf8)");
78 check([ PerlIO::get_layers(F) ],
79 [ qw[stdio encoding(utf8) utf8] ],
82 binmode(F, ":raw :crlf");
84 check([ PerlIO::get_layers(F) ],
88 binmode(F, ":raw :encoding(latin1)"); # "latin1" will be canonized
90 check([ PerlIO::get_layers(F, details => 1) ],
91 [ "stdio", undef, sub { $_[0] > 0 },
92 "encoding", "iso-8859-1", sub { $_[0] & PerlIO::F_UTF8() } ],
93 ":raw:encoding(latin1)");
97 check([ PerlIO::get_layers(F) ],
104 use open(IN => ":crlf", OUT => ":encoding(cp1252)");
109 check([ PerlIO::get_layers(F, input => 1) ],
113 check([ PerlIO::get_layers(G, output => 1) ],
114 [ qw[stdio encoding(cp1252) utf8] ],
121 1 while unlink "afile";