summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-26 13:17:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-26 13:17:30 +0000
commit9c7d3c9d595397c9f320f762b810c6335ad7787d (patch)
treee657dba9aaadee42613ba8a93bca9104eef0366d /test
parent6b380a441e4edfe64c491c1044068ec7ba9839a7 (diff)
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.rb13
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