Skip to content

Commit 59bdcb4

Browse files
herwinweregon
authored andcommitted
Add test for IO#gets setting $_ to nil after reading all lines
1 parent 3e2a193 commit 59bdcb4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/io/gets_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
end
2525
end
2626

27+
it "sets $_ to nil after the last line has been read" do
28+
while @io.gets
29+
end
30+
$_.should be_nil
31+
end
32+
2733
it "returns nil if called at the end of the stream" do
2834
IOSpecs.lines.length.times { @io.gets }
2935
@io.gets.should == nil

0 commit comments

Comments
 (0)