mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
1 changed files with 13 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue