1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Added test for keyword arguments to ARGF

This commit is contained in:
Nobuyoshi Nakada 2021-02-08 11:04:23 +09:00
parent 1ba2b5cdee
commit 1d686bdeb9
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -745,6 +745,18 @@ class TestArgf < Test::Unit::TestCase
["\"a\\n\"", "\"b\\n\""], [])
assert_in_out_err(['-e', 'ARGF.each_line(chomp: true) {|para| p para}'], "a\nb\n",
["\"a\"", "\"b\""], [])
t = make_tempfile
argf = ARGF.class.new(t.path)
lines = []
begin
argf.each_line(chomp: true) do |line|
lines << line
end
ensure
argf.close
end
assert_equal(%w[foo bar baz], lines)
end
def test_each_byte
@ -993,6 +1005,36 @@ class TestArgf < Test::Unit::TestCase
assert_nil(argf.gets, bug4274)
end
def test_readlines_chomp
t = make_tempfile
argf = ARGF.class.new(t.path)
begin
assert_equal(%w[foo bar baz], argf.readlines(chomp: true))
ensure
argf.close
end
end
def test_readline_chomp
t = make_tempfile
argf = ARGF.class.new(t.path)
begin
assert_equal("foo", argf.readline(chomp: true))
ensure
argf.close
end
end
def test_gets_chomp
t = make_tempfile
argf = ARGF.class.new(t.path)
begin
assert_equal("foo", argf.gets(chomp: true))
ensure
argf.close
end
end
def test_readlines_twice
bug5952 = '[ruby-dev:45160]'
assert_ruby_status(["-e", "2.times {STDIN.tty?; readlines}"], "", bug5952)