From f28d6165f6e39c7723ad88bdf87708ddff5a145f Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 25 Mar 2018 14:06:06 +0000 Subject: 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 --- test/ruby/test_keyword.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'test/ruby') 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 -- cgit v1.2.3