1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2015-09-26 13:17:30 +00:00
parent 6b380a441e
commit 9c7d3c9d59

View file

@ -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