mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
[ruby/stringio] Ignore chomp keyword for nil separator
nil separator means no separator at all, so nothing should be
chomped.
Partial fix for Ruby [Bug #18770]
feaa2ec631
This commit is contained in:
parent
1f82269f4e
commit
adaaf12857
2 changed files with 9 additions and 3 deletions
|
@ -92,7 +92,7 @@ class TestStringIO < Test::Unit::TestCase
|
|||
assert_equal("a", StringIO.new("a").gets(chomp: true))
|
||||
assert_equal("a", StringIO.new("a\nb").gets(chomp: true))
|
||||
assert_equal("abc", StringIO.new("abc\n\ndef\n").gets(chomp: true))
|
||||
assert_equal("abc\n\ndef", StringIO.new("abc\n\ndef\n").gets(nil, chomp: true))
|
||||
assert_equal("abc\n\ndef\n", StringIO.new("abc\n\ndef\n").gets(nil, chomp: true))
|
||||
assert_equal("abc\n", StringIO.new("abc\n\ndef\n").gets("", chomp: true))
|
||||
stringio = StringIO.new("abc\n\ndef\n")
|
||||
assert_equal("abc\n", stringio.gets("", chomp: true))
|
||||
|
@ -109,7 +109,7 @@ class TestStringIO < Test::Unit::TestCase
|
|||
assert_equal("a", StringIO.new("a").gets(chomp: true))
|
||||
assert_equal("a", StringIO.new("a\r\nb").gets(chomp: true))
|
||||
assert_equal("abc", StringIO.new("abc\r\n\r\ndef\r\n").gets(chomp: true))
|
||||
assert_equal("abc\r\n\r\ndef", StringIO.new("abc\r\n\r\ndef\r\n").gets(nil, chomp: true))
|
||||
assert_equal("abc\r\n\r\ndef\r\n", StringIO.new("abc\r\n\r\ndef\r\n").gets(nil, chomp: true))
|
||||
assert_equal("abc\r\n", StringIO.new("abc\r\n\r\ndef\r\n").gets("", chomp: true))
|
||||
stringio = StringIO.new("abc\r\n\r\ndef\r\n")
|
||||
assert_equal("abc\r\n", stringio.gets("", chomp: true))
|
||||
|
@ -605,6 +605,9 @@ class TestStringIO < Test::Unit::TestCase
|
|||
assert_equal(["foo\r\nbar\r\n\r\n", "baz\r\n"], f.each("").to_a)
|
||||
f.rewind
|
||||
assert_equal(["foo\r\nbar\r\n", "baz"], f.each("", chomp: true).to_a)
|
||||
|
||||
f = StringIO.new("abc\n\ndef\n")
|
||||
assert_equal(["ab", "c\n", "\nd", "ef", "\n"], f.each(nil, 2, chomp: true).to_a)
|
||||
end
|
||||
|
||||
def test_putc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue