Skip to content

Commit eaaec7a

Browse files
committed
Test if .lines() really is lazy (RT #112716)
1 parent 621b348 commit eaaec7a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

S16-filehandles/io.t

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ I/O tests
1515
1616
=end pod
1717

18-
plan 119;
18+
plan 125;
1919

2020
sub nonce () { return ".{$*PID}." ~ (1..1000).pick() }
2121
my $filename = 'tempfile_filehandles_io' ~ nonce();
@@ -149,6 +149,19 @@ is(@lines8[1], "Foo Bar Baz", 'lines($in,3) worked in list context');
149149
is(@lines8[2], "The End", 'lines($in,3) worked in list context');
150150
is(@lines8[3], "and finally... Its not over yet!", 'get($in) worked after lines($in,$n)');
151151
}
152+
{
153+
# test if reading a file with lines() is really lazy
154+
my $in9 = open($filename);
155+
#?niecza skip 'open does not yet produce an IO object'
156+
isa-ok($in9, IO::Handle);
157+
my $lines9 := $in9.lines;
158+
is($in9.ins, 0);
159+
for ^4 {
160+
$lines9[$_];
161+
is($in9.ins, $_ + 1);
162+
}
163+
$in9.close;
164+
}
152165

153166
{
154167
# Test $fh.lines(*) RT #125626

0 commit comments

Comments
 (0)