aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_keyword.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r--test/ruby/test_keyword.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index d0d64520e4..791d60b70a 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -284,6 +284,30 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463)
end
+ def opt_plus_keyword(x=1, **h)
+ [x, h]
+ end
+
+ def splat_plus_keyword(*a, **h)
+ [a, h]
+ end
+
+ def test_keyword_split
+ assert_equal([1, {:a=>1}], opt_plus_keyword(:a=>1))
+ assert_equal([1, {"a"=>1}], opt_plus_keyword("a"=>1))
+ assert_equal([1, {"a"=>1, :a=>1}], opt_plus_keyword("a"=>1, :a=>1))
+ assert_equal([1, {:a=>1}], opt_plus_keyword({:a=>1}))
+ assert_equal([{"a"=>1}, {}], opt_plus_keyword({"a"=>1}))
+ assert_equal([{"a"=>1}, {:a=>1}], opt_plus_keyword({"a"=>1, :a=>1}))
+
+ assert_equal([[], {:a=>1}], splat_plus_keyword(:a=>1))
+ assert_equal([[], {"a"=>1}], splat_plus_keyword("a"=>1))
+ assert_equal([[], {"a"=>1, :a=>1}], splat_plus_keyword("a"=>1, :a=>1))
+ assert_equal([[], {:a=>1}], splat_plus_keyword({:a=>1}))
+ assert_equal([[{"a"=>1}], {}], splat_plus_keyword({"a"=>1}))
+ assert_equal([[{"a"=>1}], {:a=>1}], splat_plus_keyword({"a"=>1, :a=>1}))
+ end
+
def test_bare_kwrest
# valid syntax, but its semantics is undefined
assert_valid_syntax("def bug7662(**) end")