mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
assertions for r62914
* test/ruby/test_keyword.rb (test_splat_hash): assertion on mandatory and rest arguments. r62914 is not only for optional argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a23eca2672
commit
f28d6165f6
1 changed files with 10 additions and 2 deletions
|
@ -506,8 +506,10 @@ class TestKeywordArguments < Test::Unit::TestCase
|
|||
def test_splat_hash
|
||||
m = Object.new
|
||||
def m.f() :ok; end
|
||||
def m.f1(a) a; end
|
||||
def m.f2(a = nil) a; end
|
||||
def m.f3(**a) a; end
|
||||
def m.f4(*a) a; end
|
||||
o = {a: 1}
|
||||
assert_raise_with_message(ArgumentError, /unknown keyword: a/) {
|
||||
m.f(**o)
|
||||
|
@ -518,11 +520,17 @@ class TestKeywordArguments < Test::Unit::TestCase
|
|||
assert_equal(:ok, m.f(*a, **o), '[ruby-core:83638] [Bug #10856]')
|
||||
|
||||
o = {a: 42}
|
||||
assert_warning(/splat keyword/, 'splat to mandatory') do
|
||||
assert_equal({a: 42}, m.f1(**o))
|
||||
end
|
||||
assert_warning(/splat keyword/) do
|
||||
assert_equal({a: 42}, m.f2(**o), '[ruby-core:82280] [Bug #13791]')
|
||||
end
|
||||
assert_warning('') do
|
||||
assert_equal({a: 42}, m.f3(**o), 'splat to kwrest')
|
||||
assert_warning('', 'splat to kwrest') do
|
||||
assert_equal({a: 42}, m.f3(**o))
|
||||
end
|
||||
assert_warning('', 'splat to rest') do
|
||||
assert_equal([{a: 42}], m.f4(**o))
|
||||
end
|
||||
|
||||
assert_warning('') do
|
||||
|
|
Loading…
Add table
Reference in a new issue