summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-25 14:06:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-25 14:06:06 +0000
commitf28d6165f6e39c7723ad88bdf87708ddff5a145f (patch)
tree0c467bb37164c278c281722a0db79d42916da515 /test/ruby
parenta23eca2672e68e4fa913b30c418080aa7a5d1cbf (diff)
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
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_keyword.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index 59008f7d5b..8bf5d71f8e 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -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