3 use IO::Handle; # ungetc()
5 use Test::More tests => 20;
7 require_ok q{PerlIO::scalar};
10 Internals::SvREADONLY($s, 1);
14 like $@, qr/Modification of a read-only value/, '$s is readonly';
16 ok open(my $io, '<', \$s), 'open';
23 is $io->ungetc($a), $a, 'ungetc';
26 is getc($io), chr($a), 'getc';
28 is $s, 'foo', '$s remains "foo"';
30 is getc($io), 'o', 'getc/2';
31 is getc($io), 'o', 'getc/3';
32 is getc($io), undef, 'getc/4';
34 for my $c($a .. ($a+10)){
35 is $io->ungetc($c), $c, "ungetc($c)";