Fix keyword argument sepration issues when IO#open calls #to_open
This commit is contained in:
parent
5b9d646944
commit
0aa267f985
Notes:
git
2019-09-27 00:02:34 +09:00
@ -2279,6 +2279,19 @@ class TestIO < Test::Unit::TestCase
|
||||
assert_equal(o, o2)
|
||||
end
|
||||
|
||||
def test_open_redirect_keyword
|
||||
o = Object.new
|
||||
def o.to_open(**kw); kw; end
|
||||
assert_equal({:a=>1}, open(o, a: 1))
|
||||
assert_warn(/The last argument is used as the keyword parameter.*for `to_open'/m) do
|
||||
assert_equal({:a=>1}, open(o, {a: 1}))
|
||||
end
|
||||
|
||||
def o.to_open(kw); kw; end
|
||||
assert_equal({:a=>1}, open(o, a: 1))
|
||||
assert_equal({:a=>1}, open(o, {a: 1}))
|
||||
end
|
||||
|
||||
def test_open_pipe
|
||||
open("|" + EnvUtil.rubybin, "r+") do |f|
|
||||
f.puts "puts 'foo'"
|
||||
|
Loading…
x
Reference in New Issue
Block a user