diff options
| author | Jeremy Evans <code@jeremyevans.net> | 2019-08-20 12:29:51 -0700 |
|---|---|---|
| committer | Jeremy Evans <code@jeremyevans.net> | 2019-08-30 12:39:31 -0700 |
| commit | 856bb3c35d5d81481b2e5dd00353298e8a0c2ee7 (patch) | |
| tree | 02844dc2808b315f85ecf71f460e2d49e43d53d4 /test/ruby | |
| parent | 42adc5bc6bb532e20bf2191ad99781ee701dea36 (diff) | |
Fix remaining warning issues in the tests due to keyword argument separation
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2395
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_keyword.rb | 44 | ||||
| -rw-r--r-- | test/ruby/test_syntax.rb | 4 |
2 files changed, 36 insertions, 12 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 1e707170fd..4361b14f91 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -302,14 +302,24 @@ class TestKeywordArguments < Test::Unit::TestCase bug7665 = '[ruby-core:51278]' bug8463 = '[ruby-core:55203] [Bug #8463]' expect = [*%w[foo bar], {zzz: 42}] - assert_equal(expect, rest_keyrest(*expect), bug7665) + assert_warn(/The last argument for `rest_keyrest' .* is used as the keyword parameter/) do + assert_equal(expect, rest_keyrest(*expect), bug7665) + end pr = proc {|*args, **opt| next *args, opt} - assert_equal(expect, pr.call(*expect), bug7665) - assert_equal(expect, pr.call(expect), bug8463) + assert_warn(/The last argument for `call' is used as the keyword parameter/) do + assert_equal(expect, pr.call(*expect), bug7665) + end + assert_warn(/The last argument for `call' is used as the keyword parameter/) do + assert_equal(expect, pr.call(expect), bug8463) + end pr = proc {|a, *b, **opt| next a, *b, opt} - assert_equal(expect, pr.call(expect), bug8463) + assert_warn(/The last argument for `call' is used as the keyword parameter/) do + assert_equal(expect, pr.call(expect), bug8463) + end pr = proc {|a, **opt| next a, opt} - assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463) + assert_warn(/The last argument for `call' is used as the keyword parameter/) do + assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463) + end end def opt_plus_keyword(x=1, **h) @@ -324,16 +334,24 @@ class TestKeywordArguments < Test::Unit::TestCase 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_warn(/The last argument for `opt_plus_keyword' .* is used as the keyword parameter/) do + assert_equal([1, {:a=>1}], opt_plus_keyword({:a=>1})) + end assert_equal([{"a"=>1}, {}], opt_plus_keyword({"a"=>1})) - assert_equal([{"a"=>1}, {:a=>1}], opt_plus_keyword({"a"=>1, :a=>1})) + assert_warn(/The last argument for `opt_plus_keyword' .* is split into positional and keyword parameters/) do + assert_equal([{"a"=>1}, {:a=>1}], opt_plus_keyword({"a"=>1, :a=>1})) + end 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_warn(/The last argument for `splat_plus_keyword' .* is used as the keyword parameter/) do + assert_equal([[], {:a=>1}], splat_plus_keyword({:a=>1})) + end assert_equal([[{"a"=>1}], {}], splat_plus_keyword({"a"=>1})) - assert_equal([[{"a"=>1}], {:a=>1}], splat_plus_keyword({"a"=>1, :a=>1})) + assert_warn(/The last argument for `splat_plus_keyword' .* is split into positional and keyword parameters/) do + assert_equal([[{"a"=>1}], {:a=>1}], splat_plus_keyword({"a"=>1, :a=>1})) + end end def test_bare_kwrest @@ -551,8 +569,12 @@ class TestKeywordArguments < Test::Unit::TestCase o = Object.new def o.to_hash() { k: 9 } end assert_equal([1, 42, [], o, :key, {}, nil], f9(1, o)) - assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016) - assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016) + assert_warn(/The last argument for `m1' .* is used as the keyword parameter/) do + assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016) + end + assert_warn(/The last argument for `m1' .* is used as the keyword parameter/) do + assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016) + end end def test_splat_hash diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 72a3cc2fc7..85ff68ec25 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -155,7 +155,9 @@ class TestSyntax < Test::Unit::TestCase h = {k3: 31} assert_raise(ArgumentError) {o.kw(**h)} h = {"k1"=>11, k2: 12} - assert_raise(ArgumentError) {o.kw(**h)} + assert_warn(/The last argument for `kw' .* is split into positional and keyword parameters/) do + assert_raise(ArgumentError) {o.kw(**h)} + end end def test_keyword_duplicated |
