diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-26 13:17:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-26 13:17:30 +0000 |
commit | 68933cd658fad1b899f5a89f414957e1011055ef (patch) | |
tree | e657dba9aaadee42613ba8a93bca9104eef0366d /test | |
parent | c5c20752a8a471c16f8d410d9be00dd22fd6ceed (diff) | |
download | ruby-68933cd658fad1b899f5a89f414957e1011055ef.tar.gz |
test_syntax.rb: split
* test/ruby/test_syntax.rb (test_keyword_splat): split duplicate
keywords tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_syntax.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index e4a623208a..a047454513 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -102,24 +102,33 @@ class TestSyntax < Test::Unit::TestCase assert_nothing_raised(ArgumentError, bug7922) {o.bug7922(foo: 42)} end + class KW2 + def kw(k1: 1, k2: 2) [k1, k2] end + end + def test_keyword_splat assert_valid_syntax("foo(**h)", __FILE__) - o = Object.new - def o.kw(k1: 1, k2: 2) [k1, k2] end + o = KW2.new h = {k1: 11, k2: 12} assert_equal([11, 12], o.kw(**h)) assert_equal([11, 12], o.kw(k2: 22, **h)) assert_equal([11, 22], o.kw(**h, **{k2: 22})) assert_equal([11, 12], o.kw(**{k2: 22}, **h)) + end + def test_keyword_duplicated_splat bug10315 = '[ruby-core:65368] [Bug #10315]' + + o = KW2.new assert_equal([23, 2], o.kw(**{k1: 22}, **{k1: 23}), bug10315) h = {k3: 31} assert_raise(ArgumentError) {o.kw(**h)} h = {"k1"=>11, k2: 12} assert_raise(TypeError) {o.kw(**h)} + end + def test_keyword_duplicated bug10315 = '[ruby-core:65625] [Bug #10315]' a = [] def a.add(x) push(x); x; end |