Skip to content

Commit

Permalink
Add test for IO#gets setting $_ to nil after reading all lines
Browse files Browse the repository at this point in the history
  • Loading branch information
herwinw authored and eregon committed Oct 8, 2023
1 parent 3e2a193 commit 59bdcb4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/io/gets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
end
end

it "sets $_ to nil after the last line has been read" do
while @io.gets
end
$_.should be_nil
end

it "returns nil if called at the end of the stream" do
IOSpecs.lines.length.times { @io.gets }
@io.gets.should == nil
Expand Down

0 comments on commit 59bdcb4

Please sign in to comment.