Tidy up comments.
[p5sagit/p5-mst-13.2.git] / ext / PerlIO-scalar / t / scalar_ungetc.t
CommitLineData
d85e265b 1#!perl -w
2use strict;
3use IO::Handle; # ungetc()
4
5use Test::More tests => 20;
6
7require_ok q{PerlIO::scalar};
8
9my $s = 'foo';
10Internals::SvREADONLY($s, 1);
11eval{
12 $s = 'bar';
13};
14like $@, qr/Modification of a read-only value/, '$s is readonly';
15
16ok open(my $io, '<', \$s), 'open';
17
18getc $io;
19
20my $a = ord 'A';
21
22note "buffer[$s]";
23is $io->ungetc($a), $a, 'ungetc';
24note "buffer[$s]";
25
26is getc($io), chr($a), 'getc';
27
28is $s, 'foo', '$s remains "foo"';
29
30is getc($io), 'o', 'getc/2';
31is getc($io), 'o', 'getc/3';
32is getc($io), undef, 'getc/4';
33
34for my $c($a .. ($a+10)){
35 is $io->ungetc($c), $c, "ungetc($c)";
36}