1#!./perl
2
3BEGIN {
4    unless ( PerlIO::Layer->find('perlio') ) {
5	print "1..0 # Skip: not perlio\n";
6	exit 0;
7    }
8}
9
10require($ENV{PERL_CORE} ? "../../t/test.pl" : "./t/test.pl");
11
12my $buf_size_count = 8200;      # Above default buffer size of 8192
13
14plan(tests => 5 + 2 * $buf_size_count);
15
16my $io;
17
18use_ok('IO::File');
19
20$io = IO::File->new;
21
22ok($io->open("io_utf8", ">:utf8"), "open >:utf8");
23ok((print $io chr(256)), "print chr(256)");
24undef $io;
25
26$io = IO::File->new;
27ok($io->open("io_utf8", "<:utf8"), "open <:utf8");
28is(ord(<$io>), 256, "readline chr(256)");
29
30for my $i (0 .. $buf_size_count - 1) {
31    is($io->ungetc($i), $i, "ungetc of $i returns itself");
32}
33
34for (my $i = $buf_size_count - 1; $i >= 0; $i--) {
35    is(ord($io->getc()), $i, "getc gets back $i");
36}
37
38undef $io;
39
40END {
41  1 while unlink "io_utf8";
42}
43