diff options
author | Jeremy Evans <[email protected]> | 2022-05-26 12:22:42 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2022-07-21 12:55:24 -0700 |
commit | 7223c0da152114c84e1c4261a282faaea21646fb (patch) | |
tree | 92ec924c4c538126b2552e42190dd2d2844d0cd0 /spec/ruby/core | |
parent | 3a5ea7c688b5c029ee8f69d84f49bc10b817714e (diff) |
Do not chomp trailing line separator IO#each with nil separator and chomp
nil separator means no sepator, so chomp should not remove a line
separator.
Partially Fixes [Bug #18770]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6164
Diffstat (limited to 'spec/ruby/core')
-rw-r--r-- | spec/ruby/core/io/shared/each.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/ruby/core/io/shared/each.rb b/spec/ruby/core/io/shared/each.rb index badf8985e0..607e7de03e 100644 --- a/spec/ruby/core/io/shared/each.rb +++ b/spec/ruby/core/io/shared/each.rb @@ -190,10 +190,20 @@ describe :io_each, shared: true do end describe "when passed chomp and nil as a separator" do - it "yields self's content without trailing new line character" do - @io.pos = 100 - @io.send(@method, nil, chomp: true) { |s| ScratchPad << s } - ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six."] + ruby_version_is "3.2" do + it "yields self's content" do + @io.pos = 100 + @io.send(@method, nil, chomp: true) { |s| ScratchPad << s } + ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six.\n"] + end + end + + ruby_version_is ""..."3.2" do + it "yields self's content without trailing new line character" do + @io.pos = 100 + @io.send(@method, nil, chomp: true) { |s| ScratchPad << s } + ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six."] + end end end |