mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
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]
This commit is contained in:
parent
672925bf14
commit
04f86ad0b5
Notes:
git
2022-07-22 00:14:02 +09:00
2 changed files with 15 additions and 2 deletions
|
@ -312,7 +312,7 @@ class TestIO < Test::Unit::TestCase
|
|||
w.print "a\n\nb\n\n"
|
||||
w.close
|
||||
end, proc do |r|
|
||||
assert_equal "a\n\nb\n", r.gets(nil, chomp: true)
|
||||
assert_equal("a\n\nb\n\n", r.gets(nil, chomp: true), "[Bug #18770]")
|
||||
assert_nil r.gets("")
|
||||
r.close
|
||||
end)
|
||||
|
@ -1894,6 +1894,20 @@ class TestIO < Test::Unit::TestCase
|
|||
assert_equal("baz\n", e.next)
|
||||
assert_raise(StopIteration) { e.next }
|
||||
end)
|
||||
|
||||
pipe(proc do |w|
|
||||
w.write "foo\n"
|
||||
w.close
|
||||
end, proc do |r|
|
||||
assert_equal(["foo\n"], r.each_line(nil, chomp: true).to_a, "[Bug #18770]")
|
||||
end)
|
||||
|
||||
pipe(proc do |w|
|
||||
w.write "foo\n"
|
||||
w.close
|
||||
end, proc do |r|
|
||||
assert_equal(["fo", "o\n"], r.each_line(nil, 2, chomp: true).to_a, "[Bug #18770]")
|
||||
end)
|
||||
end
|
||||
|
||||
def test_each_byte2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue