From ff96565686c05919bcae3ea77831879e95f67457 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 4 Oct 2019 15:41:13 -0700 Subject: Update tests for full keyword argument separation --- test/-ext-/funcall/test_passing_block.rb | 23 +- test/-ext-/test_scan_args.rb | 121 +- test/ruby/test_exception.rb | 3 +- test/ruby/test_io.rb | 23 +- test/ruby/test_keyword.rb | 1920 ++++++++---------------------- test/ruby/test_marshal.rb | 7 +- test/ruby/test_numeric.rb | 9 +- test/ruby/test_proc.rb | 112 +- test/ruby/test_struct.rb | 2 +- test/ruby/test_syntax.rb | 16 +- test/rubygems/test_require.rb | 10 +- test/test_delegate.rb | 4 +- 12 files changed, 556 insertions(+), 1694 deletions(-) (limited to 'test') diff --git a/test/-ext-/funcall/test_passing_block.rb b/test/-ext-/funcall/test_passing_block.rb index d1164871b0..71c9d905be 100644 --- a/test/-ext-/funcall/test_passing_block.rb +++ b/test/-ext-/funcall/test_passing_block.rb @@ -24,14 +24,10 @@ class TestFuncall < Test::Unit::TestCase def test_with_funcall_passing_block_kw block = ->(*a, **kw) { [a, kw] } assert_equal([[1], {}], Relay.with_funcall_passing_block_kw(0, 1, &block)) + assert_equal([[{a: 1}], {}], Relay.with_funcall_passing_block_kw(0, a: 1, &block)) assert_equal([[], {a: 1}], Relay.with_funcall_passing_block_kw(1, a: 1, &block)) assert_equal([[1], {a: 1}], Relay.with_funcall_passing_block_kw(1, 1, a: 1, &block)) - assert_equal([[{}], {}], Relay.with_funcall_passing_block_kw(2, {}, **{}, &block)) assert_equal([[], {a: 1}], Relay.with_funcall_passing_block_kw(3, a: 1, &block)) - assert_equal([[{a: 1}], {}], Relay.with_funcall_passing_block_kw(3, {a: 1}, **{}, &block)) - assert_warn(/warning: Passing the keyword argument as the last hash parameter is deprecated.*The called method is defined here/m) do - assert_equal({}, Relay.with_funcall_passing_block_kw(3, **{}, &->(a){a})) - end end def test_with_funcallv_public_kw @@ -47,29 +43,18 @@ class TestFuncall < Test::Unit::TestCase arg end assert_equal([[1], {}], Relay.with_funcallv_public_kw(o, :foo, 0, 1)) + assert_equal([[{a: 1}], {}], Relay.with_funcallv_public_kw(o, :foo, 0, a: 1)) assert_equal([[], {a: 1}], Relay.with_funcallv_public_kw(o, :foo, 1, a: 1)) assert_equal([[1], {a: 1}], Relay.with_funcallv_public_kw(o, :foo, 1, 1, a: 1)) - assert_equal([[{}], {}], Relay.with_funcallv_public_kw(o, :foo, 2, {}, **{})) assert_equal([[], {a: 1}], Relay.with_funcallv_public_kw(o, :foo, 3, a: 1)) - assert_equal([[{a: 1}], {}], Relay.with_funcallv_public_kw(o, :foo, 3, {a: 1}, **{})) - assert_raise(NoMethodError) { Relay.with_funcallv_public_kw(o, :bar, 3, {a: 1}, **{}) } - assert_warn(/warning: Passing the keyword argument as the last hash parameter is deprecated.*The called method `baz'/m) do - assert_equal({}, Relay.with_funcallv_public_kw(o, :baz, 3, **{})) - end end def test_with_yield_splat_kw block = ->(*a, **kw) { [a, kw] } assert_equal([[1], {}], Relay.with_yield_splat_kw(0, [1], &block)) + assert_equal([[{a: 1}], {}], Relay.with_yield_splat_kw(0, [{a: 1}], &block)) assert_equal([[], {a: 1}], Relay.with_yield_splat_kw(1, [{a: 1}], &block)) assert_equal([[1], {a: 1}], Relay.with_yield_splat_kw(1, [1, {a: 1}], &block)) - assert_equal([[{}], {}], Relay.with_yield_splat_kw(2, [{}], **{}, &block)) - assert_warn(/warning: Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[], {a: 1}], Relay.with_yield_splat_kw(3, [{a: 1}], &block)) - end - assert_equal([[{a: 1}], {}], Relay.with_yield_splat_kw(3, [{a: 1}], **{}, &block)) - assert_warn(/warning: Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal({}, Relay.with_yield_splat_kw(3, [], **{}, &->(a){a})) - end + assert_equal([[], {a: 1}], Relay.with_yield_splat_kw(3, [{a: 1}], &block)) end end diff --git a/test/-ext-/test_scan_args.rb b/test/-ext-/test_scan_args.rb index dda016d6af..92d696d69e 100644 --- a/test/-ext-/test_scan_args.rb +++ b/test/-ext-/test_scan_args.rb @@ -93,14 +93,10 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([1, "a", nil], Bug::ScanArgs.lead_hash("a")) assert_raise(ArgumentError) {Bug::ScanArgs.lead_hash("a", "b")} assert_equal([1, "a", {b: 1}], Bug::ScanArgs.lead_hash("a", b: 1)) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, {b: 1}, nil], Bug::ScanArgs.lead_hash(b: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.lead_hash(b: 1)} assert_equal([1, {"a"=>0, b: 1}, nil], Bug::ScanArgs.lead_hash({"a"=>0, b: 1}, **{})) assert_raise(ArgumentError) {Bug::ScanArgs.lead_hash(1, {"a"=>0, b: 1}, **{})} - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, {}, nil], Bug::ScanArgs.lead_hash(**{})) - end + assert_raise(ArgumentError) {Bug::ScanArgs.lead_hash(**{})} end def test_opt_hash @@ -109,9 +105,7 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([0, nil, {b: 1}], Bug::ScanArgs.opt_hash(b: 1)) assert_equal([1, "a", {b: 1}], Bug::ScanArgs.opt_hash("a", b: 1)) assert_raise(ArgumentError) {Bug::ScanArgs.opt_hash("a", "b")} - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([1, {"a"=>0}, {b: 1}], Bug::ScanArgs.opt_hash("a"=>0, b: 1)) - end + assert_equal([0, nil, {"a"=>0, b: 1}], Bug::ScanArgs.opt_hash("a"=>0, b: 1)) assert_equal([1, {"a"=>0, b: 1}, nil], Bug::ScanArgs.opt_hash({"a"=>0, b: 1}, **{})) end @@ -120,13 +114,9 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([2, "a", "b", nil], Bug::ScanArgs.lead_opt_hash("a", "b")) assert_equal([1, "a", nil, {c: 1}], Bug::ScanArgs.lead_opt_hash("a", c: 1)) assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.lead_opt_hash("a", "b", c: 1)) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.lead_opt_hash(c: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_hash(c: 1)} assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_hash("a", "b", "c")} - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_hash("a", "b"=>0, c: 1)) - end + assert_equal([1, "a", nil, {"b"=>0, c: 1}], Bug::ScanArgs.lead_opt_hash("a", "b"=>0, c: 1)) end def test_var_hash @@ -134,9 +124,7 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([1, ["a"], nil], Bug::ScanArgs.var_hash("a")) assert_equal([1, ["a"], {b: 1}], Bug::ScanArgs.var_hash("a", b: 1)) assert_equal([0, [], {b: 1}], Bug::ScanArgs.var_hash(b: 1)) - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([1, [{"a"=>0}], {b: 1}], Bug::ScanArgs.var_hash("a"=>0, b: 1)) - end + assert_equal([0, [], {"a"=>0, b: 1}], Bug::ScanArgs.var_hash("a"=>0, b: 1)) end def test_lead_var_hash @@ -145,13 +133,9 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([2, "a", ["b"], nil], Bug::ScanArgs.lead_var_hash("a", "b")) assert_equal([2, "a", ["b"], {c: 1}], Bug::ScanArgs.lead_var_hash("a", "b", c: 1)) assert_equal([1, "a", [], {c: 1}], Bug::ScanArgs.lead_var_hash("a", c: 1)) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, {c: 1}, [], nil], Bug::ScanArgs.lead_var_hash(c: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.lead_var_hash(c: 1)} assert_equal([3, "a", ["b", "c"], nil], Bug::ScanArgs.lead_var_hash("a", "b", "c")) - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([2, "a", [{"b"=>0}], {c: 1}], Bug::ScanArgs.lead_var_hash("a", "b"=>0, c: 1)) - end + assert_equal([1, "a", [], {"b"=>0, c: 1}], Bug::ScanArgs.lead_var_hash("a", "b"=>0, c: 1)) end def test_opt_var_hash @@ -162,9 +146,7 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([1, "a", [], {c: 1}], Bug::ScanArgs.opt_var_hash("a", c: 1)) assert_equal([0, nil, [], {c: 1}], Bug::ScanArgs.opt_var_hash(c: 1)) assert_equal([3, "a", ["b", "c"], nil], Bug::ScanArgs.opt_var_hash("a", "b", "c")) - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([2, "a", [{"b"=>0}], {c: 1}], Bug::ScanArgs.opt_var_hash("a", "b"=>0, c: 1)) - end + assert_equal([1, "a", [], {"b"=>0, c: 1}], Bug::ScanArgs.opt_var_hash("a", "b"=>0, c: 1)) end def test_lead_opt_var_hash @@ -173,14 +155,10 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([2, "a", "b", [], nil], Bug::ScanArgs.lead_opt_var_hash("a", "b")) assert_equal([2, "a", "b", [], {c: 1}], Bug::ScanArgs.lead_opt_var_hash("a", "b", c: 1)) assert_equal([1, "a", nil, [], {c: 1}], Bug::ScanArgs.lead_opt_var_hash("a", c: 1)) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, {c: 1}, nil, [], nil], Bug::ScanArgs.lead_opt_var_hash(c: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_var_hash(c: 1)} assert_equal([3, "a", "b", ["c"], nil], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c")) assert_equal([3, "a", "b", ["c"], {d: 1}], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c", d: 1)) - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([3, "a", "b", [{"c"=>0}], {d: 1}], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c"=>0, d: 1)) - end + assert_equal([2, "a", "b", [], {"c"=>0, d: 1}], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c"=>0, d: 1)) end def test_opt_trail_hash @@ -189,13 +167,9 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([2, "a", "b", nil], Bug::ScanArgs.opt_trail_hash("a", "b")) assert_equal([1, nil, "a", {c: 1}], Bug::ScanArgs.opt_trail_hash("a", c: 1)) assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.opt_trail_hash("a", "b", c: 1)) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, nil, {c: 1}, nil], Bug::ScanArgs.opt_trail_hash(c: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.opt_trail_hash(c: 1)} assert_raise(ArgumentError) {Bug::ScanArgs.opt_trail_hash("a", "b", "c")} - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.opt_trail_hash("a", "b"=>0, c: 1)) - end + assert_equal([1, nil, "a", {"b"=>0, c: 1}], Bug::ScanArgs.opt_trail_hash("a", "b"=>0, c: 1)) end def test_lead_opt_trail_hash @@ -203,16 +177,12 @@ class TestScanArgs < Test::Unit::TestCase assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_trail_hash("a")} assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_trail_hash(c: 1)} assert_equal([2, "a", nil, "b", nil], Bug::ScanArgs.lead_opt_trail_hash("a", "b")) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([2, "a", nil, {c: 1}, nil], Bug::ScanArgs.lead_opt_trail_hash("a", c: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_trail_hash("a", c: 1)} assert_equal([2, "a", nil, "b", {c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", c: 1)) assert_equal([3, "a", "b", "c", nil], Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c")) assert_equal([3, "a", "b", "c", {c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c", c: 1)) assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c", "d")} - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([3, "a", "b", {"c"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c"=>0, c: 1)) - end + assert_equal([2, "a", nil, "b", {"c"=>0, c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c"=>0, c: 1)) end def test_var_trail_hash @@ -221,62 +191,46 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([2, ["a"], "b", nil], Bug::ScanArgs.var_trail_hash("a", "b")) assert_equal([1, [], "a", {c: 1}], Bug::ScanArgs.var_trail_hash("a", c: 1)) assert_equal([2, ["a"], "b", {c: 1}], Bug::ScanArgs.var_trail_hash("a", "b", c: 1)) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, [], {c: 1}, nil], Bug::ScanArgs.var_trail_hash(c: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.var_trail_hash(c: 1)} assert_equal([3, ["a", "b"], "c", nil], Bug::ScanArgs.var_trail_hash("a", "b", "c")) assert_equal([3, ["a", "b"], "c", {c: 1}], Bug::ScanArgs.var_trail_hash("a", "b", "c", c: 1)) - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([3, ["a", "b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.var_trail_hash("a", "b", "c"=>0, c: 1)) - end + assert_equal([2, ["a"], "b", {"c"=>0, c: 1}], Bug::ScanArgs.var_trail_hash("a", "b", "c"=>0, c: 1)) end def test_lead_var_trail_hash assert_raise(ArgumentError) {Bug::ScanArgs.lead_var_trail_hash()} assert_raise(ArgumentError) {Bug::ScanArgs.lead_var_trail_hash("a")} assert_raise(ArgumentError) {Bug::ScanArgs.lead_var_trail_hash(c: 1)} - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([2, "a", [], {c: 1}, nil], Bug::ScanArgs.lead_var_trail_hash("a", c: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.lead_var_trail_hash("a", c: 1)} assert_equal([2, "a", [], "b", nil], Bug::ScanArgs.lead_var_trail_hash("a", "b")) assert_equal([2, "a", [], "b", {c: 1}], Bug::ScanArgs.lead_var_trail_hash("a", "b", c: 1)) assert_equal([3, "a", ["b"], "c", nil], Bug::ScanArgs.lead_var_trail_hash("a", "b", "c")) assert_equal([3, "a", ["b"], "c", {c: 1}], Bug::ScanArgs.lead_var_trail_hash("a", "b", "c", c: 1)) - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([3, "a", ["b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.lead_var_trail_hash("a", "b", c: 1, "c"=>0)) - end + assert_equal([2, "a", [], "b", {"c"=>0, c: 1}], Bug::ScanArgs.lead_var_trail_hash("a", "b", c: 1, "c"=>0)) end def test_opt_var_trail_hash assert_raise(ArgumentError) {Bug::ScanArgs.opt_var_trail_hash()} assert_equal([1, nil, [], "a", nil], Bug::ScanArgs.opt_var_trail_hash("a")) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, nil, [], {c: 1}, nil], Bug::ScanArgs.opt_var_trail_hash(c: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.opt_var_trail_hash(c: 1)} assert_equal([1, nil, [], "a", {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", c: 1)) assert_equal([2, "a", [], "b", nil], Bug::ScanArgs.opt_var_trail_hash("a", "b")) assert_equal([2, "a", [], "b", {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", "b", c: 1)) assert_equal([3, "a", ["b"], "c", nil], Bug::ScanArgs.opt_var_trail_hash("a", "b", "c")) assert_equal([3, "a", ["b"], "c", {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", "b", "c", c: 1)) - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([3, "a", ["b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", "b", "c"=>0, c: 1)) - end + assert_equal([2, "a", [], "b", {"c"=>0, c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", "b", "c"=>0, c: 1)) end def test_lead_opt_var_trail_hash assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_var_trail_hash()} assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_var_trail_hash("a")} - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([2, "a", nil, [], {b: 1}, nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", b: 1)) - end + assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_var_trail_hash("a", b: 1)} assert_equal([2, "a", nil, [], "b", nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b")) assert_equal([2, "a", nil, [], "b", {c: 1}], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", c: 1)) assert_equal([3, "a", "b", [], "c", nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c")) assert_equal([3, "a", "b", [], "c", {c: 1}], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c", c: 1)) assert_equal([4, "a", "b", ["c"], "d", nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c", "d")) - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([4, "a", "b", ["c"], {"d"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c", "d"=>0, c: 1)) - end + assert_equal([3, "a", "b", [], "c", {"d"=>0, c: 1}], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c", "d"=>0, c: 1)) end def test_k_lead_opt_hash @@ -285,25 +239,8 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([1, "a", nil, {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", {c: 1})) assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", "b", c: 1)) assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", "b", {c: 1})) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.k_lead_opt_hash(c: 1)) - end - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", "b"=>0, c: 1)) - end - end - - def test_e_lead_opt_hash - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([1, {}, nil, nil], Bug::ScanArgs.e_lead_opt_hash) - end - assert_equal([1, "a", nil, nil], Bug::ScanArgs.e_lead_opt_hash("a")) - assert_equal([2, "a", "b", nil], Bug::ScanArgs.e_lead_opt_hash("a", "b")) - assert_equal([2, "a", {c: 1}, nil], Bug::ScanArgs.e_lead_opt_hash("a", c: 1)) - assert_raise(ArgumentError) {Bug::ScanArgs.e_lead_opt_hash("a", "b", c: 1)} - assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.e_lead_opt_hash(c: 1)) - assert_raise(ArgumentError) {Bug::ScanArgs.e_lead_opt_hash("a", "b", "c")} - assert_equal([2, "a", {"b"=>0, c: 1}, nil], Bug::ScanArgs.e_lead_opt_hash("a", "b"=>0, c: 1)) + assert_raise(ArgumentError) {Bug::ScanArgs.k_lead_opt_hash(c: 1)} + assert_equal([1, "a", nil, {"b"=>0, c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", "b"=>0, c: 1)) end def test_n_lead_opt_hash @@ -314,11 +251,9 @@ class TestScanArgs < Test::Unit::TestCase assert_equal([1, "a", nil, {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", {c: 1})) assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", "b", c: 1)) assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", "b", {c: 1})) - assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.n_lead_opt_hash(c: 1)) - assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.n_lead_opt_hash({c: 1})) + assert_raise(ArgumentError) {Bug::ScanArgs.n_lead_opt_hash(c: 1)} + assert_raise(ArgumentError) {Bug::ScanArgs.n_lead_opt_hash({c: 1})} assert_raise(ArgumentError) {Bug::ScanArgs.n_lead_opt_hash("a", "b", "c")} - assert_warn(/The last argument is split into positional and keyword parameters/) do - assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", "b"=>0, c: 1)) - end + assert_equal([1, "a", nil, {"b"=>0, c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", "b"=>0, c: 1)) end end diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index c0ab23a18e..086f250a3b 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -945,8 +945,7 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| assert_raise(ArgumentError) {warn("test warning", uplevel: -1)} assert_in_out_err(["-e", "warn 'ok', uplevel: 1"], '', [], /warning:/) warning = capture_warning_warn {warn("test warning", {uplevel: 0})} - assert_equal("#{__FILE__}:#{__LINE__-1}: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call\n", warning[0]) - assert_match(/warning: The called method (?:`.*' )?is defined here|warning: test warning/, warning[1]) + assert_match(/test warning.*{:uplevel=>0}/m, warning[0]) warning = capture_warning_warn {warn("test warning", **{uplevel: 0})} assert_equal("#{__FILE__}:#{__LINE__-1}: warning: test warning\n", warning[0]) warning = capture_warning_warn {warn("test warning", {uplevel: 0}, **{})} diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index c66446d2e8..6bdc7bb27f 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2284,26 +2284,14 @@ class TestIO < Test::Unit::TestCase def o.to_open(**kw); kw; end assert_equal({:a=>1}, open(o, a: 1)) - w = /Using the last argument as keyword parameters is deprecated.*The called method `(to_)?open'/m - redefined = nil - w.singleton_class.define_method(:===) do |s| - match = super(s) - redefined = !$1 - match - end - - assert_warn(w) do - assert_equal({:a=>1}, open(o, {a: 1})) - end + assert_raise(ArgumentError) { open(o, {a: 1}) } class << o remove_method(:to_open) end def o.to_open(kw); kw; end assert_equal({:a=>1}, open(o, a: 1)) - unless redefined - assert_equal({:a=>1}, open(o, {a: 1})) - end + assert_equal({:a=>1}, open(o, {a: 1})) end def test_open_pipe @@ -3138,11 +3126,8 @@ __END__ assert_equal("\00f", File.read(path)) assert_equal(1, File.write(path, "f", 0, encoding: "UTF-8")) assert_equal("ff", File.read(path)) - assert_raise(TypeError) { - assert_warn(/The last argument is split into positional and keyword parameters/) do - File.write(path, "foo", Object.new => Object.new) - end - } + File.write(path, "foo", Object.new => Object.new) + assert_equal("foo", File.read(path)) end end diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index c3a3a450f1..c49496d6a9 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -24,9 +24,7 @@ class TestKeywordArguments < Test::Unit::TestCase def test_f2 assert_equal([:xyz, "foo", 424242], f2(:xyz)) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `f2'/m) do - assert_equal([{"bar"=>42}, "foo", 424242], f2("bar"=>42)) - end + assert_raise(ArgumentError) { f2("bar"=>42) } end @@ -224,12 +222,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.m(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.m(**kw)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } assert_equal(kw, c.m(kw, **kw)) assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) @@ -248,39 +242,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.m(**h2)) assert_equal(h3, c.m(**h3)) assert_equal(h3, c.m(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, c.m(h)) - end + assert_raise(ArgumentError) { c.m(h) } assert_raise(ArgumentError) { c.m(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { c.m(h3) } - end + assert_raise(ArgumentError) { c.m(h3) } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.m(**{}) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.m(**kw) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.m(**h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.m(a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], c.m(**h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.m(**h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.m(a: 1, **h2)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } + assert_raise(ArgumentError) { c.m(**h) } + assert_raise(ArgumentError) { c.m(a: 1) } + assert_raise(ArgumentError) { c.m(**h2) } + assert_raise(ArgumentError) { c.m(**h3) } + assert_raise(ArgumentError) { c.m(a: 1, **h2) } assert_equal([h, kw], c.m(h)) assert_equal([h2, kw], c.m(h2)) assert_equal([h3, kw], c.m(h3)) @@ -296,13 +272,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, h2], c.m(**h2)) assert_equal([1, h3], c.m(**h3)) assert_equal([1, h3], c.m(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal([1, h], c.m(h)) - end + assert_equal([h, kw], c.m(h)) assert_equal([h2, kw], c.m(h2)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_equal([h2, h], c.m(h3)) - end + assert_equal([h3, kw], c.m(h3)) end def test_implicit_super_kwsplat @@ -313,19 +285,9 @@ class TestKeywordArguments < Test::Unit::TestCase sc = Class.new c = sc.new - redef = -> do - if defined?(c.m) - class << c - remove_method(:m) - end - end - eval <<-END - def c.m(*args, **kw) - super(*args, **kw) - end - END + def c.m(*args, **kw) + super(*args, **kw) end - redef[] sc.class_eval do def m(*args) args @@ -357,13 +319,8 @@ class TestKeywordArguments < Test::Unit::TestCase args end end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.m(**{})) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.m(**kw)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) assert_equal(h2, c.m(**h2)) @@ -383,13 +340,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.m(**h2)) assert_equal(h3, c.m(**h3)) assert_equal(h3, c.m(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, c.m(h)) - end + assert_raise(ArgumentError) { c.m(h) } assert_raise(ArgumentError) { c.m(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { c.m(h3) } - end + assert_raise(ArgumentError) { c.m(h3) } sc.class_eval do remove_method(:m) @@ -397,34 +350,13 @@ class TestKeywordArguments < Test::Unit::TestCase [arg, args] end end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.m(**{}) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.m(**kw) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.m(**h)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.m(a: 1)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], c.m(**h2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.m(**h3)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.m(a: 1, **h2)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } + assert_raise(ArgumentError) { c.m(**h) } + assert_raise(ArgumentError) { c.m(a: 1) } + assert_raise(ArgumentError) { c.m(**h2) } + assert_raise(ArgumentError) { c.m(**h3) } + assert_raise(ArgumentError) { c.m(a: 1, **h2) } sc.class_eval do remove_method(:m) @@ -449,19 +381,9 @@ class TestKeywordArguments < Test::Unit::TestCase sc = Class.new c = sc.new - redef = -> do - if defined?(c.m) - class << c - remove_method(:m) - end - end - eval <<-END - def c.m(*args, **kw) - super(*args, **kw) - end - END + def c.m(*args, **kw) + super(*args, **kw) end - redef[] sc.class_eval do def m(*args) args @@ -493,13 +415,8 @@ class TestKeywordArguments < Test::Unit::TestCase args end end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.m(**{})) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.m(**kw)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) assert_equal(h2, c.m(**h2)) @@ -519,13 +436,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.m(**h2)) assert_equal(h3, c.m(**h3)) assert_equal(h3, c.m(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, c.m(h)) - end + assert_raise(ArgumentError) { c.m(h) } assert_raise(ArgumentError) { c.m(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { c.m(h3) } - end + assert_raise(ArgumentError) { c.m(h3) } sc.class_eval do remove_method(:m) @@ -533,34 +446,13 @@ class TestKeywordArguments < Test::Unit::TestCase [arg, args] end end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.m(**{}) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.m(**kw) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.m(**h)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.m(a: 1)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], c.m(**h2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.m(**h3)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.m(a: 1, **h2)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } + assert_raise(ArgumentError) { c.m(**h) } + assert_raise(ArgumentError) { c.m(a: 1) } + assert_raise(ArgumentError) { c.m(**h2) } + assert_raise(ArgumentError) { c.m(**h3) } + assert_raise(ArgumentError) { c.m(a: 1, **h2) } sc.class_eval do remove_method(:m) @@ -592,12 +484,8 @@ class TestKeywordArguments < Test::Unit::TestCase assert_raise(ArgumentError) { f[**h3] } f = ->(a) { a } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, f[**{}]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, f[**kw]) - end + assert_raise(ArgumentError) { f[**{}] } + assert_raise(ArgumentError) { f[**kw] } assert_equal(h, f[**h]) assert_equal(h, f[a: 1]) assert_equal(h2, f[**h2]) @@ -612,36 +500,18 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, f[**h2]) assert_equal(h3, f[**h3]) assert_equal(h3, f[a: 1, **h2]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `\[\]'/m) do - assert_equal(h, f[h]) - end + assert_raise(ArgumentError) { f[h] } assert_raise(ArgumentError) { f[h2] } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `\[\]'/m) do - assert_raise(ArgumentError) { f[h3] } - end + assert_raise(ArgumentError) { f[h3] } f = ->(a, **x) { [a,x] } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do - assert_equal([{}, {}], f[**{}]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do - assert_equal([{}, {}], f[**kw]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do - assert_equal([h, {}], f[**h]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do - assert_equal([h, {}], f[a: 1]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do - assert_equal([h2, {}], f[**h2]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do - assert_equal([h3, {}], f[**h3]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do - assert_equal([h3, {}], f[a: 1, **h2]) - end + assert_raise(ArgumentError) { f[**{}] } + assert_raise(ArgumentError) { f[**kw] } + assert_raise(ArgumentError) { f[**h] } + assert_raise(ArgumentError) { f[a: 1] } + assert_raise(ArgumentError) { f[**h2] } + assert_raise(ArgumentError) { f[**h3] } + assert_raise(ArgumentError) { f[a: 1, **h2] } f = ->(a=1, **x) { [a, x] } assert_equal([1, kw], f[**{}]) @@ -670,12 +540,8 @@ class TestKeywordArguments < Test::Unit::TestCase f = ->(a) { a } f = f.method(:call) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, f[**{}]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, f[**kw]) - end + assert_raise(ArgumentError) { f[**{}] } + assert_raise(ArgumentError) { f[**kw] } assert_equal(h, f[**h]) assert_equal(h, f[a: 1]) assert_equal(h2, f[**h2]) @@ -691,37 +557,19 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, f[**h2]) assert_equal(h3, f[**h3]) assert_equal(h3, f[a: 1, **h2]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(h, f[h]) - end + assert_raise(ArgumentError) { f[h] } assert_raise(ArgumentError) { f[h2] } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_raise(ArgumentError) { f[h3] } - end + assert_raise(ArgumentError) { f[h3] } f = ->(a, **x) { [a,x] } f = f.method(:call) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], f[**{}]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], f[**kw]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], f[**h]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], f[a: 1]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, {}], f[**h2]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], f[**h3]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], f[a: 1, **h2]) - end + assert_raise(ArgumentError) { f[**{}] } + assert_raise(ArgumentError) { f[**kw] } + assert_raise(ArgumentError) { f[**h] } + assert_raise(ArgumentError) { f[a: 1] } + assert_raise(ArgumentError) { f[**h2] } + assert_raise(ArgumentError) { f[**h3] } + assert_raise(ArgumentError) { f[a: 1, **h2] } f = ->(a=1, **x) { [a, x] } f = f.method(:call) @@ -751,12 +599,8 @@ class TestKeywordArguments < Test::Unit::TestCase assert_raise(ArgumentError) { t.new(**h3, &f).value } f = ->(a) { a } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, t.new(**{}, &f).value) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, t.new(**kw, &f).value) - end + assert_raise(ArgumentError) { t.new(**{}, &f).value } + assert_raise(ArgumentError) { t.new(**kw, &f).value } assert_equal(h, t.new(**h, &f).value) assert_equal(h, t.new(a: 1, &f).value) assert_equal(h2, t.new(**h2, &f).value) @@ -771,36 +615,18 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, t.new(**h2, &f).value) assert_equal(h3, t.new(**h3, &f).value) assert_equal(h3, t.new(a: 1, **h2, &f).value) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(h, t.new(h, &f).value) - end + assert_raise(ArgumentError) { t.new(h, &f).value } assert_raise(ArgumentError) { t.new(h2, &f).value } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_raise(ArgumentError) { t.new(h3, &f).value } - end + assert_raise(ArgumentError) { t.new(h3, &f).value } f = ->(a, **x) { [a,x] } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], t.new(**{}, &f).value) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], t.new(**kw, &f).value) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], t.new(**h, &f).value) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], t.new(a: 1, &f).value) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, {}], t.new(**h2, &f).value) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], t.new(**h3, &f).value) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], t.new(a: 1, **h2, &f).value) - end + assert_raise(ArgumentError) { t.new(**{}, &f).value } + assert_raise(ArgumentError) { t.new(**kw, &f).value } + assert_raise(ArgumentError) { t.new(**h, &f).value } + assert_raise(ArgumentError) { t.new(a: 1, &f).value } + assert_raise(ArgumentError) { t.new(**h2, &f).value } + assert_raise(ArgumentError) { t.new(**h3, &f).value } + assert_raise(ArgumentError) { t.new(a: 1, **h2, &f).value } f = ->(a=1, **x) { [a, x] } assert_equal([1, kw], t.new(**{}, &f).value) @@ -830,12 +656,8 @@ class TestKeywordArguments < Test::Unit::TestCase assert_raise(ArgumentError) { t.new(&f).resume(**h3) } f = ->(a) { a } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, t.new(&f).resume(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, t.new(&f).resume(**kw)) - end + assert_raise(ArgumentError) { t.new(&f).resume(**{}) } + assert_raise(ArgumentError) { t.new(&f).resume(**kw) } assert_equal(h, t.new(&f).resume(**h)) assert_equal(h, t.new(&f).resume(a: 1)) assert_equal(h2, t.new(&f).resume(**h2)) @@ -850,36 +672,18 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, t.new(&f).resume(**h2)) assert_equal(h3, t.new(&f).resume(**h3)) assert_equal(h3, t.new(&f).resume(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(h, t.new(&f).resume(h)) - end + assert_raise(ArgumentError) { t.new(&f).resume(h) } assert_raise(ArgumentError) { t.new(&f).resume(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_raise(ArgumentError) { t.new(&f).resume(h3) } - end + assert_raise(ArgumentError) { t.new(&f).resume(h3) } f = ->(a, **x) { [a,x] } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], t.new(&f).resume(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], t.new(&f).resume(**kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], t.new(&f).resume(**h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], t.new(&f).resume(a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, {}], t.new(&f).resume(**h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], t.new(&f).resume(**h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], t.new(&f).resume(a: 1, **h2)) - end + assert_raise(ArgumentError) { t.new(&f).resume(**{}) } + assert_raise(ArgumentError) { t.new(&f).resume(**kw) } + assert_raise(ArgumentError) { t.new(&f).resume(**h) } + assert_raise(ArgumentError) { t.new(&f).resume(a: 1) } + assert_raise(ArgumentError) { t.new(&f).resume(**h2) } + assert_raise(ArgumentError) { t.new(&f).resume(**h3) } + assert_raise(ArgumentError) { t.new(&f).resume(a: 1, **h2) } f = ->(a=1, **x) { [a, x] } assert_equal([1, kw], t.new(&f).resume(**{})) @@ -907,12 +711,8 @@ class TestKeywordArguments < Test::Unit::TestCase assert_raise(ArgumentError) { g.new(&f).each(**h3) } f = ->(_, a) { a } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, g.new(&f).each(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, g.new(&f).each(**kw)) - end + assert_raise(ArgumentError) { g.new(&f).each(**{}) } + assert_raise(ArgumentError) { g.new(&f).each(**kw) } assert_equal(h, g.new(&f).each(**h)) assert_equal(h, g.new(&f).each(a: 1)) assert_equal(h2, g.new(&f).each(**h2)) @@ -927,36 +727,18 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, g.new(&f).each(**h2)) assert_equal(h3, g.new(&f).each(**h3)) assert_equal(h3, g.new(&f).each(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(h, g.new(&f).each(h)) - end + assert_raise(ArgumentError) { g.new(&f).each(h) } assert_raise(ArgumentError) { g.new(&f).each(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_raise(ArgumentError) { g.new(&f).each(h3) } - end + assert_raise(ArgumentError) { g.new(&f).each(h3) } f = ->(_, a, **x) { [a,x] } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], g.new(&f).each(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], g.new(&f).each(**kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], g.new(&f).each(**h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], g.new(&f).each(a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, {}], g.new(&f).each(**h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], g.new(&f).each(**h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], g.new(&f).each(a: 1, **h2)) - end + assert_raise(ArgumentError) { g.new(&f).each(**{}) } + assert_raise(ArgumentError) { g.new(&f).each(**kw) } + assert_raise(ArgumentError) { g.new(&f).each(**h) } + assert_raise(ArgumentError) { g.new(&f).each(a: 1) } + assert_raise(ArgumentError) { g.new(&f).each(**h2) } + assert_raise(ArgumentError) { g.new(&f).each(**h3) } + assert_raise(ArgumentError) { g.new(&f).each(a: 1, **h2) } f = ->(_, a=1, **x) { [a, x] } assert_equal([1, kw], g.new(&f).each(**{})) @@ -984,12 +766,8 @@ class TestKeywordArguments < Test::Unit::TestCase assert_raise(ArgumentError) { g.new{|y| y.yield(**h3)}.each(&f) } f = ->(a) { a } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, g.new{|y| y.yield(**{})}.each(&f)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, g.new{|y| y.yield(**kw)}.each(&f)) - end + assert_raise(ArgumentError) { g.new{|y| y.yield(**{})}.each(&f) } + assert_raise(ArgumentError) { g.new{|y| y.yield(**kw)}.each(&f) } assert_equal(h, g.new{|y| y.yield(**h)}.each(&f)) assert_equal(h, g.new{|y| y.yield(a: 1)}.each(&f)) assert_equal(h2, g.new{|y| y.yield(**h2)}.each(&f)) @@ -1004,36 +782,18 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, g.new{|y| y.yield(**h2)}.each(&f)) assert_equal(h3, g.new{|y| y.yield(**h3)}.each(&f)) assert_equal(h3, g.new{|y| y.yield(a: 1, **h2)}.each(&f)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(h, g.new{|y| y.yield(h)}.each(&f)) - end + assert_raise(ArgumentError) { g.new{|y| y.yield(h)}.each(&f) } assert_raise(ArgumentError) { g.new{|y| y.yield(h2)}.each(&f) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_raise(ArgumentError) { g.new{|y| y.yield(h3)}.each(&f) } - end + assert_raise(ArgumentError) { g.new{|y| y.yield(h3)}.each(&f) } f = ->(a, **x) { [a,x] } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], g.new{|y| y.yield(**{})}.each(&f)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([{}, {}], g.new{|y| y.yield(**kw)}.each(&f)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], g.new{|y| y.yield(**h)}.each(&f)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, {}], g.new{|y| y.yield(a: 1)}.each(&f)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, {}], g.new{|y| y.yield(**h2)}.each(&f)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], g.new{|y| y.yield(**h3)}.each(&f)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, {}], g.new{|y| y.yield(a: 1, **h2)}.each(&f)) - end + assert_raise(ArgumentError) { g.new{|y| y.yield(**{})}.each(&f) } + assert_raise(ArgumentError) { g.new{|y| y.yield(**kw)}.each(&f) } + assert_raise(ArgumentError) { g.new{|y| y.yield(**h)}.each(&f) } + assert_raise(ArgumentError) { g.new{|y| y.yield(a: 1)}.each(&f) } + assert_raise(ArgumentError) { g.new{|y| y.yield(**h2)}.each(&f) } + assert_raise(ArgumentError) { g.new{|y| y.yield(**h3)}.each(&f) } + assert_raise(ArgumentError) { g.new{|y| y.yield(a: 1, **h2)}.each(&f) } f = ->(a=1, **x) { [a, x] } assert_equal([1, kw], g.new{|y| y.yield(**{})}.each(&f)) @@ -1087,12 +847,8 @@ class TestKeywordArguments < Test::Unit::TestCase @args = args end end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal(kw, c[**{}].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal(kw, c[**kw].args) - end + assert_raise(ArgumentError) { c[**{}] } + assert_raise(ArgumentError) { c[**kw] } assert_equal(h, c[**h].args) assert_equal(h, c[a: 1].args) assert_equal(h2, c[**h2].args) @@ -1111,40 +867,22 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c[**h2].args) assert_equal(h3, c[**h3].args) assert_equal(h3, c[a: 1, **h2].args) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `initialize'/m) do - assert_equal(h, c[h].args) - end + assert_raise(ArgumentError) { c[h].args } assert_raise(ArgumentError) { c[h2].args } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `initialize'/m) do - assert_raise(ArgumentError) { c[h3].args } - end + assert_raise(ArgumentError) { c[h3].args } c = Class.new(sc) do def initialize(arg, **args) @args = [arg, args] end end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([kw, kw], c[**{}].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([kw, kw], c[**kw].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h, kw], c[**h].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h, kw], c[a: 1].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h2, kw], c[**h2].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h3, kw], c[**h3].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h3, kw], c[a: 1, **h2].args) - end + assert_raise(ArgumentError) { c[**{}].args } + assert_raise(ArgumentError) { c[**kw].args } + assert_raise(ArgumentError) { c[**h].args } + assert_raise(ArgumentError) { c[a: 1].args } + assert_raise(ArgumentError) { c[**h2].args } + assert_raise(ArgumentError) { c[**h3].args } + assert_raise(ArgumentError) { c[a: 1, **h2].args } c = Class.new(sc) do def initialize(arg=1, **args) @@ -1199,12 +937,8 @@ class TestKeywordArguments < Test::Unit::TestCase @args = args end end.method(:new) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal(kw, c[**{}].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal(kw, c[**kw].args) - end + assert_raise(ArgumentError) { c[**{}] } + assert_raise(ArgumentError) { c[**kw] } assert_equal(h, c[**h].args) assert_equal(h, c[a: 1].args) assert_equal(h2, c[**h2].args) @@ -1223,40 +957,22 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c[**h2].args) assert_equal(h3, c[**h3].args) assert_equal(h3, c[a: 1, **h2].args) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `initialize'/m) do - assert_equal(h, c[h].args) - end + assert_raise(ArgumentError) { c[h].args } assert_raise(ArgumentError) { c[h2].args } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `initialize'/m) do - assert_raise(ArgumentError) { c[h3].args } - end + assert_raise(ArgumentError) { c[h3].args } c = Class.new(sc) do def initialize(arg, **args) @args = [arg, args] end end.method(:new) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([kw, kw], c[**{}].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([kw, kw], c[**kw].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h, kw], c[**h].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h, kw], c[a: 1].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h2, kw], c[**h2].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h3, kw], c[**h3].args) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do - assert_equal([h3, kw], c[a: 1, **h2].args) - end + assert_raise(ArgumentError) { c[**{}].args } + assert_raise(ArgumentError) { c[**kw].args } + assert_raise(ArgumentError) { c[**h].args } + assert_raise(ArgumentError) { c[a: 1].args } + assert_raise(ArgumentError) { c[**h2].args } + assert_raise(ArgumentError) { c[**h3].args } + assert_raise(ArgumentError) { c[a: 1, **h2].args } c = Class.new(sc) do def initialize(arg=1, **args) @@ -1304,12 +1020,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.method(:m)[**{}]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.method(:m)[**kw]) - end + assert_raise(ArgumentError) { c.method(:m)[**{}] } + assert_raise(ArgumentError) { c.method(:m)[**kw] } assert_equal(h, c.method(:m)[**h]) assert_equal(h, c.method(:m)[a: 1]) assert_equal(h2, c.method(:m)[**h2]) @@ -1327,39 +1039,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.method(:m)[**h2]) assert_equal(h3, c.method(:m)[**h3]) assert_equal(h3, c.method(:m)[a: 1, **h2]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, c.method(:m)[h]) - end + assert_raise(ArgumentError) { c.method(:m)[h] } assert_raise(ArgumentError) { c.method(:m)[h2] } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { c.method(:m)[h3] } - end + assert_raise(ArgumentError) { c.method(:m)[h3] } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], c.method(:m)[**{}]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], c.method(:m)[**kw]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.method(:m)[**h]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.method(:m)[a: 1]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], c.method(:m)[**h2]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.method(:m)[**h3]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.method(:m)[a: 1, **h2]) - end + assert_raise(ArgumentError) { c.method(:m)[**{}] } + assert_raise(ArgumentError) { c.method(:m)[**kw] } + assert_raise(ArgumentError) { c.method(:m)[**h] } + assert_raise(ArgumentError) { c.method(:m)[a: 1] } + assert_raise(ArgumentError) { c.method(:m)[**h2] } + assert_raise(ArgumentError) { c.method(:m)[**h3] } + assert_raise(ArgumentError) { c.method(:m)[a: 1, **h2] } c.singleton_class.remove_method(:m) def c.m(arg=1, **args) @@ -1407,12 +1101,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, sc.instance_method(:m).bind_call(c, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, sc.instance_method(:m).bind_call(c, **kw)) - end + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **{}) } + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **kw) } assert_equal(h, sc.instance_method(:m).bind_call(c, **h)) assert_equal(h, sc.instance_method(:m).bind_call(c, a: 1)) assert_equal(h2, sc.instance_method(:m).bind_call(c, **h2)) @@ -1430,39 +1120,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, sc.instance_method(:m).bind_call(c, **h2)) assert_equal(h3, sc.instance_method(:m).bind_call(c, **h3)) assert_equal(h3, sc.instance_method(:m).bind_call(c, a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, sc.instance_method(:m).bind_call(c, h)) - end + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, h) } assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, h3) } - end + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, h3) } sc.remove_method(:m) def c.m(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], sc.instance_method(:m).bind_call(c, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], sc.instance_method(:m).bind_call(c, **kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], sc.instance_method(:m).bind_call(c, **h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], sc.instance_method(:m).bind_call(c, a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], sc.instance_method(:m).bind_call(c, **h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], sc.instance_method(:m).bind_call(c, **h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], sc.instance_method(:m).bind_call(c, a: 1, **h2)) - end + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **{}) } + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **kw) } + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **h) } + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, a: 1) } + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **h2) } + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **h3) } + assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, a: 1, **h2) } sc.remove_method(:m) def c.m(arg=1, **args) @@ -1509,12 +1181,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.send(:m, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.send(:m, **kw)) - end + assert_raise(ArgumentError) { c.send(:m, **{}) } + assert_raise(ArgumentError) { c.send(:m, **kw) } assert_equal(h, c.send(:m, **h)) assert_equal(h, c.send(:m, a: 1)) assert_equal(h2, c.send(:m, **h2)) @@ -1532,39 +1200,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.send(:m, **h2)) assert_equal(h3, c.send(:m, **h3)) assert_equal(h3, c.send(:m, a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, c.send(:m, h)) - end + assert_raise(ArgumentError) { c.send(:m, h) } assert_raise(ArgumentError) { c.send(:m, h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { c.send(:m, h3) } - end + assert_raise(ArgumentError) { c.send(:m, h3) } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.send(:m, **{}) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.send(:m, **kw) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.send(:m, **h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.send(:m, a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], c.send(:m, **h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.send(:m, **h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.send(:m, a: 1, **h2)) - end + assert_raise(ArgumentError) { c.send(:m, **{}) } + assert_raise(ArgumentError) { c.send(:m, **kw) } + assert_raise(ArgumentError) { c.send(:m, **h) } + assert_raise(ArgumentError) { c.send(:m, a: 1) } + assert_raise(ArgumentError) { c.send(:m, **h2) } + assert_raise(ArgumentError) { c.send(:m, **h3) } + assert_raise(ArgumentError) { c.send(:m, a: 1, **h2) } c.singleton_class.remove_method(:m) def c.m(arg=1, **args) @@ -1611,12 +1261,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.public_send(:m, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.public_send(:m, **kw)) - end + assert_raise(ArgumentError) { c.public_send(:m, **{}) } + assert_raise(ArgumentError) { c.public_send(:m, **kw) } assert_equal(h, c.public_send(:m, **h)) assert_equal(h, c.public_send(:m, a: 1)) assert_equal(h2, c.public_send(:m, **h2)) @@ -1634,39 +1280,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.public_send(:m, **h2)) assert_equal(h3, c.public_send(:m, **h3)) assert_equal(h3, c.public_send(:m, a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, c.public_send(:m, h)) - end + assert_raise(ArgumentError) { c.public_send(:m, h) } assert_raise(ArgumentError) { c.public_send(:m, h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { c.public_send(:m, h3) } - end + assert_raise(ArgumentError) { c.public_send(:m, h3) } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.public_send(:m, **{}) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - c.public_send(:m, **kw) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.public_send(:m, **h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.public_send(:m, a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], c.public_send(:m, **h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.public_send(:m, **h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.public_send(:m, a: 1, **h2)) - end + assert_raise(ArgumentError) { c.public_send(:m, **{}) } + assert_raise(ArgumentError) { c.public_send(:m, **kw) } + assert_raise(ArgumentError) { c.public_send(:m, **h) } + assert_raise(ArgumentError) { c.public_send(:m, a: 1) } + assert_raise(ArgumentError) { c.public_send(:m, **h2) } + assert_raise(ArgumentError) { c.public_send(:m, **h3) } + assert_raise(ArgumentError) { c.public_send(:m, a: 1, **h2) } c.singleton_class.remove_method(:m) def c.m(arg=1, **args) @@ -1716,12 +1344,8 @@ class TestKeywordArguments < Test::Unit::TestCase args end m = c.method(:send) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, m.call(:m, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, m.call(:m, **kw)) - end + assert_raise(ArgumentError) { m.call(:m, **{}) } + assert_raise(ArgumentError) { m.call(:m, **kw) } assert_equal(h, m.call(:m, **h)) assert_equal(h, m.call(:m, a: 1)) assert_equal(h2, m.call(:m, **h2)) @@ -1740,40 +1364,22 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, m.call(:m, **h2)) assert_equal(h3, m.call(:m, **h3)) assert_equal(h3, m.call(:m, a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, m.call(:m, h)) - end + assert_raise(ArgumentError) { m.call(:m, h) } assert_raise(ArgumentError) { m.call(:m, h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { m.call(:m, h3) } - end + assert_raise(ArgumentError) { m.call(:m, h3) } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end m = c.method(:send) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - m.call(:m, **{}) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - m.call(:m, **kw) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], m.call(:m, **h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], m.call(:m, a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], m.call(:m, **h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], m.call(:m, **h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], m.call(:m, a: 1, **h2)) - end + assert_raise(ArgumentError) { m.call(:m, **{}) } + assert_raise(ArgumentError) { m.call(:m, **kw) } + assert_raise(ArgumentError) { m.call(:m, **h) } + assert_raise(ArgumentError) { m.call(:m, a: 1) } + assert_raise(ArgumentError) { m.call(:m, **h2) } + assert_raise(ArgumentError) { m.call(:m, **h3) } + assert_raise(ArgumentError) { m.call(:m, a: 1, **h2) } c.singleton_class.remove_method(:m) def c.m(arg=1, **args) @@ -1821,12 +1427,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, :m.to_proc.call(c, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, :m.to_proc.call(c, **kw)) - end + assert_raise(ArgumentError) { :m.to_proc.call(c, **{}) } + assert_raise(ArgumentError) { :m.to_proc.call(c, **kw) } assert_equal(h, :m.to_proc.call(c, **h)) assert_equal(h, :m.to_proc.call(c, a: 1)) assert_equal(h2, :m.to_proc.call(c, **h2)) @@ -1844,39 +1446,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, :m.to_proc.call(c, **h2)) assert_equal(h3, :m.to_proc.call(c, **h3)) assert_equal(h3, :m.to_proc.call(c, a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, :m.to_proc.call(c, h)) - end + assert_raise(ArgumentError) { :m.to_proc.call(c, h) } assert_raise(ArgumentError) { :m.to_proc.call(c, h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { :m.to_proc.call(c, h3) } - end + assert_raise(ArgumentError) { :m.to_proc.call(c, h3) } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], :m.to_proc.call(c, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], :m.to_proc.call(c, **kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], :m.to_proc.call(c, **h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], :m.to_proc.call(c, a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], :m.to_proc.call(c, **h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], :m.to_proc.call(c, **h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], :m.to_proc.call(c, a: 1, **h2)) - end + assert_raise(ArgumentError) { :m.to_proc.call(c, **{}) } + assert_raise(ArgumentError) { :m.to_proc.call(c, **kw) } + assert_raise(ArgumentError) { :m.to_proc.call(c, **h) } + assert_raise(ArgumentError) { :m.to_proc.call(c, a: 1) } + assert_raise(ArgumentError) { :m.to_proc.call(c, **h2) } + assert_raise(ArgumentError) { :m.to_proc.call(c, **h3) } + assert_raise(ArgumentError) { :m.to_proc.call(c, a: 1, **h2) } c.singleton_class.remove_method(:m) def c.m(arg=1, **args) @@ -1924,12 +1508,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, m.call(c, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, m.call(c, **kw)) - end + assert_raise(ArgumentError) { m.call(c, **{}) } + assert_raise(ArgumentError) { m.call(c, **kw) } assert_equal(h, m.call(c, **h)) assert_equal(h, m.call(c, a: 1)) assert_equal(h2, m.call(c, **h2)) @@ -1947,39 +1527,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, m.call(c, **h2)) assert_equal(h3, m.call(c, **h3)) assert_equal(h3, m.call(c, a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, m.call(c, h)) - end + assert_raise(ArgumentError) { m.call(c, h) } assert_raise(ArgumentError) { m.call(c, h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { m.call(c, h3) } - end + assert_raise(ArgumentError) { m.call(c, h3) } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], m.call(c, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], m.call(c, **kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], m.call(c, **h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], m.call(c, a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], m.call(c, **h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], m.call(c, **h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], m.call(c, a: 1, **h2)) - end + assert_raise(ArgumentError) { m.call(c, **{}) } + assert_raise(ArgumentError) { m.call(c, **kw) } + assert_raise(ArgumentError) { m.call(c, **h) } + assert_raise(ArgumentError) { m.call(c, a: 1) } + assert_raise(ArgumentError) { m.call(c, **h2) } + assert_raise(ArgumentError) { m.call(c, **h3) } + assert_raise(ArgumentError) { m.call(c, a: 1, **h2) } c.singleton_class.remove_method(:m) def c.m(arg=1, **args) @@ -2026,12 +1588,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.method_missing(_, args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.m(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.m(**kw)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) assert_equal(h2, c.m(**h2)) @@ -2049,39 +1607,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.m(**h2)) assert_equal(h3, c.m(**h3)) assert_equal(h3, c.m(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal(h, c.m(h)) - end + assert_raise(ArgumentError) { c.m(h) } assert_raise(ArgumentError) { c.m(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_raise(ArgumentError) { c.m(h3) } - end + assert_raise(ArgumentError) { c.m(h3) } c.singleton_class.remove_method(:method_missing) def c.method_missing(_, arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.m(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.m(**kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.m(**h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.m(a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h2, kw], c.m(**h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.m(**h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.m(a: 1, **h2)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } + assert_raise(ArgumentError) { c.m(**h) } + assert_raise(ArgumentError) { c.m(a: 1) } + assert_raise(ArgumentError) { c.m(**h2) } + assert_raise(ArgumentError) { c.m(**h3) } + assert_raise(ArgumentError) { c.m(a: 1, **h2) } c.singleton_class.remove_method(:method_missing) def c.method_missing(_, arg=1, **args) @@ -2128,22 +1668,12 @@ class TestKeywordArguments < Test::Unit::TestCase assert_raise(ArgumentError) { c.m(**h3) } assert_raise(ArgumentError) { c.m(a: 1, **h2) } - redef = -> do - c.singleton_class.remove_method(:method_missing) - eval <<-END - def c.method_missing(_, args) - args - end - END - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.m(**{})) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.m(**kw)) + c.singleton_class.remove_method(:method_missing) + def c.method_missing(_, args) + args end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) assert_equal(h2, c.m(**h2)) @@ -2161,50 +1691,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.m(**h2)) assert_equal(h3, c.m(**h3)) assert_equal(h3, c.m(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do - assert_equal(h, c.m(h)) - end + assert_raise(ArgumentError) { c.m(h) } assert_raise(ArgumentError) { c.m(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do - assert_raise(ArgumentError) { c.m(h3) } - end + assert_raise(ArgumentError) { c.m(h3) } - redef = -> do - c.singleton_class.remove_method(:method_missing) - eval <<-END - def c.method_missing(_, arg, **args) - [arg, args] - end - END - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.m(**{})) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.m(**kw)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.m(**h)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.m(a: 1)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h2, kw], c.m(**h2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.m(**h3)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.m(a: 1, **h2)) + c.singleton_class.remove_method(:method_missing) + def c.method_missing(_, arg, **args) + [arg, args] end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } + assert_raise(ArgumentError) { c.m(**h) } + assert_raise(ArgumentError) { c.m(a: 1) } + assert_raise(ArgumentError) { c.m(**h2) } + assert_raise(ArgumentError) { c.m(**h3) } + assert_raise(ArgumentError) { c.m(a: 1, **h2) } c.singleton_class.remove_method(:method_missing) def c.method_missing(_, arg=1, **args) @@ -2252,12 +1753,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.method_missing(_, args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.m(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.m(**kw)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) assert_equal(h2, c.m(**h2)) @@ -2275,39 +1772,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.m(**h2)) assert_equal(h3, c.m(**h3)) assert_equal(h3, c.m(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal(h, c.m(h)) - end + assert_raise(ArgumentError) { c.m(h) } assert_raise(ArgumentError) { c.m(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_raise(ArgumentError) { c.m(h3) } - end + assert_raise(ArgumentError) { c.m(h3) } c.singleton_class.remove_method(:method_missing) def c.method_missing(_, arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.m(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.m(**kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.m(**h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.m(a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h2, kw], c.m(**h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.m(**h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.m(a: 1, **h2)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } + assert_raise(ArgumentError) { c.m(**h) } + assert_raise(ArgumentError) { c.m(a: 1) } + assert_raise(ArgumentError) { c.m(**h2) } + assert_raise(ArgumentError) { c.m(**h3) } + assert_raise(ArgumentError) { c.m(a: 1, **h2) } c.singleton_class.remove_method(:method_missing) def c.method_missing(_, arg=1, **args) @@ -2344,12 +1823,8 @@ class TestKeywordArguments < Test::Unit::TestCase class << c define_method(:m) {|arg| arg } end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, c.m(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, c.m(**kw)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) assert_equal(h2, c.m(**h2)) @@ -2379,39 +1854,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.m(**h2)) assert_equal(h3, c.m(**h3)) assert_equal(h3, c.m(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated/m) do - assert_equal(h, c.m(h)) - end + assert_raise(ArgumentError) { c.m(h) } assert_raise(ArgumentError) { c.m(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do - assert_raise(ArgumentError) { c.m(h3) } - end + assert_raise(ArgumentError) { c.m(h3) } c = Object.new class << c define_method(:m) {|arg, **opt| [arg, opt] } end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([kw, kw], c.m(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([kw, kw], c.m(**kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h, kw], c.m(**h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h, kw], c.m(a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h2, kw], c.m(**h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h3, kw], c.m(**h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h3, kw], c.m(a: 1, **h2)) - end + assert_raise(ArgumentError) { c.m(**{}) } + assert_raise(ArgumentError) { c.m(**kw) } + assert_raise(ArgumentError) { c.m(**h) } + assert_raise(ArgumentError) { c.m(a: 1) } + assert_raise(ArgumentError) { c.m(**h2) } + assert_raise(ArgumentError) { c.m(**h3) } + assert_raise(ArgumentError) { c.m(a: 1, **h2) } c = Object.new class << c @@ -2429,23 +1886,15 @@ class TestKeywordArguments < Test::Unit::TestCase class << c define_method(:m) {|*args, **opt| [args, opt] } end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[], h], c.m(h)) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[h], h], c.m(h, h)) - end + assert_equal([[h], kw], c.m(h)) + assert_equal([[h, h], kw], c.m(h, h)) c = Object.new class << c define_method(:m) {|arg=nil, a: nil| [arg, a] } end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([h2, 1], c.m(h3)) - end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([h2, 1], c.m(**h3)) - end + assert_equal([h3, nil], c.m(h3)) + assert_raise(ArgumentError) { c.m(**h3) } end def test_define_method_method_kwsplat @@ -2472,12 +1921,8 @@ class TestKeywordArguments < Test::Unit::TestCase define_method(:m) {|arg| arg } end m = c.method(:m) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, m.call(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, m.call(**kw)) - end + assert_raise(ArgumentError) { m.call(**{}) } + assert_raise(ArgumentError) { m.call(**kw) } assert_equal(h, m.call(**h)) assert_equal(h, m.call(a: 1)) assert_equal(h2, m.call(**h2)) @@ -2509,40 +1954,22 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, m.call(**h2)) assert_equal(h3, m.call(**h3)) assert_equal(h3, m.call(a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated/m) do - assert_equal(h, m.call(h)) - end + assert_raise(ArgumentError) { m.call(h) } assert_raise(ArgumentError) { m.call(h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do - assert_raise(ArgumentError) { m.call(h3) } - end + assert_raise(ArgumentError) { m.call(h3) } c = Object.new class << c define_method(:m) {|arg, **opt| [arg, opt] } end m = c.method(:m) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([kw, kw], m.call(**{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([kw, kw], m.call(**kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h, kw], m.call(**h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h, kw], m.call(a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h2, kw], m.call(**h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h3, kw], m.call(**h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h3, kw], m.call(a: 1, **h2)) - end + assert_raise(ArgumentError) { m.call(**{}) } + assert_raise(ArgumentError) { m.call(**kw) } + assert_raise(ArgumentError) { m.call(**h) } + assert_raise(ArgumentError) { m.call(a: 1) } + assert_raise(ArgumentError) { m.call(**h2) } + assert_raise(ArgumentError) { m.call(**h3) } + assert_raise(ArgumentError) { m.call(a: 1, **h2) } c = Object.new class << c @@ -2562,24 +1989,16 @@ class TestKeywordArguments < Test::Unit::TestCase define_method(:m) {|*args, **opt| [args, opt] } end m = c.method(:m) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[], h], m.call(h)) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[h], h], m.call(h, h)) - end + assert_equal([[h], kw], m.call(h)) + assert_equal([[h, h], kw], m.call(h, h)) c = Object.new class << c define_method(:m) {|arg=nil, a: nil| [arg, a] } end m = c.method(:m) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([h2, 1], m.call(h3)) - end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([h2, 1], m.call(**h3)) - end + assert_equal([h3, nil], m.call(h3)) + assert_raise(ArgumentError) { m.call(**h3) } end def test_attr_reader_kwsplat @@ -2631,12 +2050,8 @@ class TestKeywordArguments < Test::Unit::TestCase class << c attr_writer :m end - assert_warn(/Passing the keyword argument for `m=' as the last hash parameter is deprecated/) do - c.send(:m=, **{}) - end - assert_warn(/Passing the keyword argument for `m=' as the last hash parameter is deprecated/) do - c.send(:m=, **kw) - end + assert_raise(ArgumentError) { c.send(:m=, **{}) } + assert_raise(ArgumentError) { c.send(:m=, **kw) } assert_equal(h, c.send(:m=, **h)) assert_equal(h, c.send(:m=, a: 1)) assert_equal(h2, c.send(:m=, **h2)) @@ -2663,12 +2078,8 @@ class TestKeywordArguments < Test::Unit::TestCase attr_writer :m end m = c.method(:m=) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - m.call(**{}) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - m.call(**kw) - end + assert_raise(ArgumentError) { m.call(**{}) } + assert_raise(ArgumentError) { m.call(**kw) } assert_equal(h, m.call(**h)) assert_equal(h, m.call(a: 1)) assert_equal(h2, m.call(**h2)) @@ -2691,13 +2102,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([[1], h1], foo.call(1, :a=>1, &->(*args, **kw){[args, kw]})) assert_equal([1, h1], foo.call(1, :a=>1, &->(*args){args})) - assert_warn(/Using the last argument as keyword parameters is deprecated/) do - assert_equal([[1], h1], foo.call(1, {:a=>1}, &->(*args, **kw){[args, kw]})) - end + assert_equal([[1, h1], {}], foo.call(1, {:a=>1}, &->(*args, **kw){[args, kw]})) assert_equal([1, h1], foo.call(1, {:a=>1}, &->(*args){args})) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h1, {}], foo.call(:a=>1, &->(arg, **kw){[arg, kw]})) - end + assert_raise(ArgumentError) { foo.call(:a=>1, &->(arg, **kw){[arg, kw]}) } assert_equal(h1, foo.call(:a=>1, &->(arg){arg})) [->(){}, ->(arg){}, ->(*args, **kw){}, ->(*args, k: 1){}, ->(*args, k: ){}].each do |pr| @@ -2913,21 +2320,13 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([[h1], {}], o.foo_foo_bar(h1, **{})) assert_equal([h1], o.foo_foo_baz(h1, **{})) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do - assert_equal([[1], h1], o.foo(:bar, 1, h1)) - end + assert_equal([[1, h1], {}], o.foo(:bar, 1, h1)) assert_equal([1, h1], o.foo(:baz, 1, h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do - assert_equal([[1], h1], o.bfoo(:bar, 1, h1)) - end + assert_equal([[1, h1], {}], o.bfoo(:bar, 1, h1)) assert_equal([1, h1], o.bfoo(:baz, 1, h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do - assert_equal([[1], h1], o.store_foo(:bar, 1, h1)) - end + assert_equal([[1, h1], {}], o.store_foo(:bar, 1, h1)) assert_equal([1, h1], o.store_foo(:baz, 1, h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do - assert_equal([[1], h1], o.foo_bar(1, h1)) - end + assert_equal([[1, h1], {}], o.foo_bar(1, h1)) assert_equal([1, h1], o.foo_baz(1, h1)) assert_equal([[1, h1, 1], {}], o.foo_mod(:bar, 1, :a=>1)) @@ -2977,43 +2376,29 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([[h1], {}], o.foo_dbar(h1, **{})) assert_equal([h1], o.foo_dbaz(h1, **{})) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[1], h1], o.foo(:dbar, 1, h1)) - end + assert_equal([[1, h1], {}], o.foo(:dbar, 1, h1)) assert_equal([1, h1], o.foo(:dbaz, 1, h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[1], h1], o.bfoo(:dbar, 1, h1)) - end + assert_equal([[1, h1], {}], o.bfoo(:dbar, 1, h1)) assert_equal([1, h1], o.bfoo(:dbaz, 1, h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[1], h1], o.store_foo(:dbar, 1, h1)) - end + assert_equal([[1, h1], {}], o.store_foo(:dbar, 1, h1)) assert_equal([1, h1], o.store_foo(:dbaz, 1, h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal([[1], h1], o.foo_dbar(1, h1)) - end + assert_equal([[1, h1], {}], o.foo_dbar(1, h1)) assert_equal([1, h1], o.foo_dbaz(1, h1)) assert_equal([[1], h1], o.block(1, :a=>1)) assert_equal([[1], h1], o.block(1, **h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal([[1], h1], o.block(1, h1)) - end + assert_equal([[1, h1], {}], o.block(1, h1)) assert_equal([[h1], {}], o.block(h1, **{})) assert_equal([[1], h1], o.cfunc(1, :a=>1)) assert_equal([[1], h1], o.cfunc(1, **h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `initialize'/m) do - assert_equal([[1], h1], o.cfunc(1, h1)) - end + assert_equal([[1, h1], {}], o.cfunc(1, h1)) assert_equal([[h1], {}], o.cfunc(h1, **{})) o = mmkw.new assert_equal([[:b, 1], h1], o.b(1, :a=>1)) assert_equal([[:b, 1], h1], o.b(1, **h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal([[:b, 1], h1], o.b(1, h1)) - end + assert_equal([[:b, 1, h1], {}], o.b(1, h1)) assert_equal([[:b, h1], {}], o.b(h1, **{})) o = mmnokw.new @@ -3025,9 +2410,7 @@ class TestKeywordArguments < Test::Unit::TestCase o = implicit_super.new assert_equal([[1], h1], o.bar(1, :a=>1)) assert_equal([[1], h1], o.bar(1, **h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do - assert_equal([[1], h1], o.bar(1, h1)) - end + assert_equal([[1, h1], {}], o.bar(1, h1)) assert_equal([[h1], {}], o.bar(h1, **{})) assert_equal([1, h1], o.baz(1, :a=>1)) @@ -3038,9 +2421,7 @@ class TestKeywordArguments < Test::Unit::TestCase o = explicit_super.new assert_equal([[1], h1], o.bar(1, :a=>1)) assert_equal([[1], h1], o.bar(1, **h1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do - assert_equal([[1], h1], o.bar(1, h1)) - end + assert_equal([[1, h1], {}], o.bar(1, h1)) assert_equal([[h1], {}], o.bar(h1, **{})) assert_equal([1, h1], o.baz(1, :a=>1)) @@ -3048,19 +2429,8 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, h1], o.baz(1, h1)) assert_equal([h1], o.baz(h1, **{})) - c.class_eval do - remove_method(:bar) - def bar(*args, **kw) - [args, kw] - end - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do - assert_equal([[1], h1], o.foo(:pass_bar, 1, :a=>1)) - end - - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `initialize'/m) do - assert_equal([[1], h1], o.foo(:pass_cfunc, 1, :a=>1)) - end + assert_equal([[1, h1], {}], o.foo(:pass_bar, 1, :a=>1)) + assert_equal([[1, h1], {}], o.foo(:pass_cfunc, 1, :a=>1)) assert_warn(/Skipping set of ruby2_keywords flag for bar \(method accepts keywords or method does not accept argument splat\)/) do assert_nil(c.send(:ruby2_keywords, :bar)) @@ -3148,25 +2518,14 @@ class TestKeywordArguments < Test::Unit::TestCase end assert_equal(c, [c].dig(0, **{})) assert_equal(c, [c].dig(0, **kw)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal(h, [c].dig(0, **h)) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal(h, [c].dig(0, a: 1)) - end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do - assert_raise(ArgumentError) { [c].dig(0, **h3) } - end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do - assert_raise(ArgumentError) { [c].dig(0, a: 1, **h2) } - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal(h, [c].dig(0, h)) - end + assert_raise(ArgumentError) { [c].dig(0, **h) } + assert_raise(ArgumentError) { [c].dig(0, a: 1) } + assert_raise(ArgumentError) { [c].dig(0, **h2) } + assert_raise(ArgumentError) { [c].dig(0, **h3) } + assert_raise(ArgumentError) { [c].dig(0, a: 1, **h2) } + assert_raise(ArgumentError) { [c].dig(0, h) } assert_raise(ArgumentError) { [c].dig(0, h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do - assert_raise(ArgumentError) { [c].dig(0, h3) } - end + assert_raise(ArgumentError) { [c].dig(0, h3) } c.singleton_class.remove_method(:dig) def c.dig(arg, **args) @@ -3186,26 +2545,14 @@ class TestKeywordArguments < Test::Unit::TestCase end assert_equal(c, [c].dig(0, **{})) assert_equal(c, [c].dig(0, **kw)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal([1, h], [c].dig(0, **h)) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal([1, h], [c].dig(0, a: 1)) - end + assert_equal([h, kw], [c].dig(0, **h)) + assert_equal([h, kw], [c].dig(0, a: 1)) assert_equal([h2, kw], [c].dig(0, **h2)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal([h2, h], [c].dig(0, **h3)) - end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal([h2, h], [c].dig(0, a: 1, **h2)) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal([1, h], [c].dig(0, h)) - end + assert_equal([h3, kw], [c].dig(0, **h3)) + assert_equal([h3, kw], [c].dig(0, a: 1, **h2)) + assert_equal([h, {}], [c].dig(0, h)) assert_equal([h2, kw], [c].dig(0, h2)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do - assert_equal([h2, h], [c].dig(0, h3)) - end + assert_equal([h3, kw], [c].dig(0, h3)) assert_equal([h, kw], [c].dig(0, h, **{})) assert_equal([h2, kw], [c].dig(0, h2, **{})) assert_equal([h3, kw], [c].dig(0, h3, **{})) @@ -3258,25 +2605,14 @@ class TestKeywordArguments < Test::Unit::TestCase end assert_equal(c, [c].dig(0, **{})) assert_equal(c, [c].dig(0, **kw)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal(h, [c].dig(0, **h)) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal(h, [c].dig(0, a: 1)) - end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_raise(ArgumentError) { [c].dig(0, **h3) } - end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_raise(ArgumentError) { [c].dig(0, a: 1, **h2) } - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal(h, [c].dig(0, h)) - end + assert_raise(ArgumentError) { [c].dig(0, **h) } + assert_raise(ArgumentError) { [c].dig(0, a: 1) } + assert_raise(ArgumentError) { [c].dig(0, **h2) } + assert_raise(ArgumentError) { [c].dig(0, **h3) } + assert_raise(ArgumentError) { [c].dig(0, a: 1, **h2) } + assert_raise(ArgumentError) { [c].dig(0, h) } assert_raise(ArgumentError) { [c].dig(0, h2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_raise(ArgumentError) { [c].dig(0, h3) } - end + assert_raise(ArgumentError) { [c].dig(0, h3) } c.singleton_class.remove_method(:method_missing) def c.method_missing(_, arg, **args) @@ -3296,26 +2632,14 @@ class TestKeywordArguments < Test::Unit::TestCase end assert_equal(c, [c].dig(0, **{})) assert_equal(c, [c].dig(0, **kw)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal([1, h], [c].dig(0, **h)) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal([1, h], [c].dig(0, a: 1)) - end + assert_equal([h, kw], [c].dig(0, **h)) + assert_equal([h, kw], [c].dig(0, a: 1)) assert_equal([h2, kw], [c].dig(0, **h2)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal([h2, h], [c].dig(0, **h3)) - end - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal([h2, h], [c].dig(0, a: 1, **h2)) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal([1, h], [c].dig(0, h)) - end + assert_equal([h3, kw], [c].dig(0, **h3)) + assert_equal([h3, kw], [c].dig(0, a: 1, **h2)) + assert_equal([h, kw], [c].dig(0, h)) assert_equal([h2, kw], [c].dig(0, h2)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do - assert_equal([h2, h], [c].dig(0, h3)) - end + assert_equal([h3, kw], [c].dig(0, h3)) assert_equal([h, kw], [c].dig(0, h, **{})) assert_equal([h2, kw], [c].dig(0, h2, **{})) assert_equal([h3, kw], [c].dig(0, h3, **{})) @@ -3348,12 +2672,8 @@ class TestKeywordArguments < Test::Unit::TestCase assert_raise(ArgumentError) { c.to_enum(:each, a: 1, **h2, &m).size } m = ->(args){ args } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, c.to_enum(:each, **{}, &m).size) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal(kw, c.to_enum(:each, **kw, &m).size) - end + assert_raise(ArgumentError) { c.to_enum(:each, **{}, &m).size } + assert_raise(ArgumentError) { c.to_enum(:each, **kw, &m).size } assert_equal(kw, c.to_enum(:each, kw, **kw, &m).size) assert_equal(h, c.to_enum(:each, **h, &m).size) assert_equal(h, c.to_enum(:each, a: 1, &m).size) @@ -3369,36 +2689,18 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.to_enum(:each, **h2, &m).size) assert_equal(h3, c.to_enum(:each, **h3, &m).size) assert_equal(h3, c.to_enum(:each, a: 1, **h2, &m).size) - assert_warn(/Using the last argument as keyword parameters is deprecated/m) do - assert_equal(h, c.to_enum(:each, h, &m).size) - end + assert_raise(ArgumentError) { c.to_enum(:each, h, &m).size } assert_raise(ArgumentError) { c.to_enum(:each, h2, &m).size } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do - assert_raise(ArgumentError) { c.to_enum(:each, h3, &m).size } - end + assert_raise(ArgumentError) { c.to_enum(:each, h3, &m).size } m = ->(arg, **args){ [arg, args] } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - c.to_enum(:each, **{}, &m).size - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - c.to_enum(:each, **kw, &m).size - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h, kw], c.to_enum(:each, **h, &m).size) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h, kw], c.to_enum(:each, a: 1, &m).size) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h2, kw], c.to_enum(:each, **h2, &m).size) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h3, kw], c.to_enum(:each, **h3, &m).size) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do - assert_equal([h3, kw], c.to_enum(:each, a: 1, **h2, &m).size) - end + assert_raise(ArgumentError) { c.to_enum(:each, **{}, &m).size } + assert_raise(ArgumentError) { c.to_enum(:each, **kw, &m).size } + assert_raise(ArgumentError) { c.to_enum(:each, **h, &m).size } + assert_raise(ArgumentError) { c.to_enum(:each, a: 1, &m).size } + assert_raise(ArgumentError) { c.to_enum(:each, **h2, &m).size } + assert_raise(ArgumentError) { c.to_enum(:each, **h3, &m).size } + assert_raise(ArgumentError) { c.to_enum(:each, a: 1, **h2, &m).size } assert_equal([h, kw], c.to_enum(:each, h, &m).size) assert_equal([h2, kw], c.to_enum(:each, h2, &m).size) assert_equal([h3, kw], c.to_enum(:each, h3, &m).size) @@ -3411,13 +2713,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, h2], c.to_enum(:each, **h2, &m).size) assert_equal([1, h3], c.to_enum(:each, **h3, &m).size) assert_equal([1, h3], c.to_enum(:each, a: 1, **h2, &m).size) - assert_warn(/Using the last argument as keyword parameters is deprecated/m) do - assert_equal([1, h], c.to_enum(:each, h, &m).size) - end + assert_equal([h, kw], c.to_enum(:each, h, &m).size) assert_equal([h2, kw], c.to_enum(:each, h2, &m).size) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do - assert_equal([h2, h], c.to_enum(:each, h3, &m).size) - end + assert_equal([h3, kw], c.to_enum(:each, h3, &m).size) end def test_instance_exec_kwsplat @@ -3446,12 +2744,8 @@ class TestKeywordArguments < Test::Unit::TestCase assert_raise(ArgumentError) { c.instance_exec(a: 1, **h2, &m) } m = ->(args) { args } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal(kw, c.instance_exec(**{}, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal(kw, c.instance_exec(**kw, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(**{}, &m) } + assert_raise(ArgumentError) { c.instance_exec(**kw, &m) } assert_equal(kw, c.instance_exec(kw, **kw, &m)) assert_equal(h, c.instance_exec(**h, &m)) assert_equal(h, c.instance_exec(a: 1, &m)) @@ -3467,36 +2761,18 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.instance_exec(**h2, &m)) assert_equal(h3, c.instance_exec(**h3, &m)) assert_equal(h3, c.instance_exec(a: 1, **h2, &m)) - assert_warn(/Using the last argument as keyword parameters is deprecated/) do - assert_equal(h, c.instance_exec(h, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(h, &m) } assert_raise(ArgumentError) { c.instance_exec(h2, &m) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do - assert_raise(ArgumentError) { c.instance_exec(h3, &m) } - end + assert_raise(ArgumentError) { c.instance_exec(h3, &m) } m = ->(arg, **args) { [arg, args] } - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - c.instance_exec(**{}, &m) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - c.instance_exec(**kw, &m) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, kw], c.instance_exec(**h, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, kw], c.instance_exec(a: 1, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, kw], c.instance_exec(**h2, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, kw], c.instance_exec(**h3, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, kw], c.instance_exec(a: 1, **h2, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(**{}, &m) } + assert_raise(ArgumentError) { c.instance_exec(**kw, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h, &m) } + assert_raise(ArgumentError) { c.instance_exec(a: 1, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h2, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h3, &m) } + assert_raise(ArgumentError) { c.instance_exec(a: 1, **h2, &m) } assert_equal([h, kw], c.instance_exec(h, &m)) assert_equal([h2, kw], c.instance_exec(h2, &m)) assert_equal([h3, kw], c.instance_exec(h3, &m)) @@ -3509,13 +2785,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, h2], c.instance_exec(**h2, &m)) assert_equal([1, h3], c.instance_exec(**h3, &m)) assert_equal([1, h3], c.instance_exec(a: 1, **h2, &m)) - assert_warn(/Using the last argument as keyword parameters is deprecated/m) do - assert_equal([1, h], c.instance_exec(h, &m)) - end + assert_equal([h, kw], c.instance_exec(h, &m)) assert_equal([h2, kw], c.instance_exec(h2, &m)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do - assert_equal([h2, h], c.instance_exec(h3, &m)) - end + assert_equal([h3, kw], c.instance_exec(h3, &m)) end def test_instance_exec_method_kwsplat @@ -3554,12 +2826,8 @@ class TestKeywordArguments < Test::Unit::TestCase args end m = c.method(:m) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal(kw, c.instance_exec(**{}, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal(kw, c.instance_exec(**kw, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(**{}, &m) } + assert_raise(ArgumentError) { c.instance_exec(**kw, &m) } assert_equal(kw, c.instance_exec(kw, **kw, &m)) assert_equal(h, c.instance_exec(**h, &m)) assert_equal(h, c.instance_exec(a: 1, &m)) @@ -3579,40 +2847,22 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.instance_exec(**h2, &m)) assert_equal(h3, c.instance_exec(**h3, &m)) assert_equal(h3, c.instance_exec(a: 1, **h2, &m)) - assert_warn(/Using the last argument as keyword parameters is deprecated/) do - assert_equal(h, c.instance_exec(h, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(h, &m) } assert_raise(ArgumentError) { c.instance_exec(h2, &m) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do - assert_raise(ArgumentError) { c.instance_exec(h3, &m) } - end + assert_raise(ArgumentError) { c.instance_exec(h3, &m) } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end m = c.method(:m) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - c.instance_exec(**{}, &m) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - c.instance_exec(**kw, &m) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, kw], c.instance_exec(**h, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, kw], c.instance_exec(a: 1, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, kw], c.instance_exec(**h2, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, kw], c.instance_exec(**h3, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, kw], c.instance_exec(a: 1, **h2, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(**{}, &m) } + assert_raise(ArgumentError) { c.instance_exec(**kw, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h, &m) } + assert_raise(ArgumentError) { c.instance_exec(a: 1, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h2, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h3, &m) } + assert_raise(ArgumentError) { c.instance_exec(a: 1, **h2, &m) } assert_equal([h, kw], c.instance_exec(h, &m)) assert_equal([h2, kw], c.instance_exec(h2, &m)) assert_equal([h3, kw], c.instance_exec(h3, &m)) @@ -3629,13 +2879,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, h2], c.instance_exec(**h2, &m)) assert_equal([1, h3], c.instance_exec(**h3, &m)) assert_equal([1, h3], c.instance_exec(a: 1, **h2, &m)) - assert_warn(/Using the last argument as keyword parameters is deprecated/m) do - assert_equal([1, h], c.instance_exec(h, &m)) - end + assert_equal([h, kw], c.instance_exec(h, &m)) assert_equal([h2, kw], c.instance_exec(h2, &m)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do - assert_equal([h2, h], c.instance_exec(h3, &m)) - end + assert_equal([h3, kw], c.instance_exec(h3, &m)) end def test_instance_exec_define_method_kwsplat @@ -3674,12 +2920,8 @@ class TestKeywordArguments < Test::Unit::TestCase args end m = c.method(:m) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal(kw, c.instance_exec(**{}, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal(kw, c.instance_exec(**kw, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(**{}, &m) } + assert_raise(ArgumentError) { c.instance_exec(**kw, &m) } assert_equal(kw, c.instance_exec(kw, **kw, &m)) assert_equal(h, c.instance_exec(**h, &m)) assert_equal(h, c.instance_exec(a: 1, &m)) @@ -3699,40 +2941,22 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.instance_exec(**h2, &m)) assert_equal(h3, c.instance_exec(**h3, &m)) assert_equal(h3, c.instance_exec(a: 1, **h2, &m)) - assert_warn(/Using the last argument as keyword parameters is deprecated/) do - assert_equal(h, c.instance_exec(h, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(h, &m) } assert_raise(ArgumentError) { c.instance_exec(h2, &m) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do - assert_raise(ArgumentError) { c.instance_exec(h3, &m) } - end + assert_raise(ArgumentError) { c.instance_exec(h3, &m) } c.singleton_class.remove_method(:m) c.define_singleton_method(:m) do |arg, **args| [arg, args] end m = c.method(:m) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - c.instance_exec(**{}, &m) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - c.instance_exec(**kw, &m) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, kw], c.instance_exec(**h, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, kw], c.instance_exec(a: 1, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, kw], c.instance_exec(**h2, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, kw], c.instance_exec(**h3, &m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, kw], c.instance_exec(a: 1, **h2, &m)) - end + assert_raise(ArgumentError) { c.instance_exec(**{}, &m) } + assert_raise(ArgumentError) { c.instance_exec(**kw, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h, &m) } + assert_raise(ArgumentError) { c.instance_exec(a: 1, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h2, &m) } + assert_raise(ArgumentError) { c.instance_exec(**h3, &m) } + assert_raise(ArgumentError) { c.instance_exec(a: 1, **h2, &m) } assert_equal([h, kw], c.instance_exec(h, &m)) assert_equal([h2, kw], c.instance_exec(h2, &m)) assert_equal([h3, kw], c.instance_exec(h3, &m)) @@ -3749,13 +2973,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, h2], c.instance_exec(**h2, &m)) assert_equal([1, h3], c.instance_exec(**h3, &m)) assert_equal([1, h3], c.instance_exec(a: 1, **h2, &m)) - assert_warn(/Using the last argument as keyword parameters is deprecated/m) do - assert_equal([1, h], c.instance_exec(h, &m)) - end + assert_equal([h, kw], c.instance_exec(h, &m)) assert_equal([h2, kw], c.instance_exec(h2, &m)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do - assert_equal([h2, h], c.instance_exec(h3, &m)) - end + assert_equal([h3, kw], c.instance_exec(h3, &m)) end def test_instance_exec_sym_proc_kwsplat @@ -3791,12 +3011,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal(kw, c.instance_exec(c, **{}, &:m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal(kw, c.instance_exec(c, **kw, &:m)) - end + assert_raise(ArgumentError) { c.instance_exec(c, **{}, &:m) } + assert_raise(ArgumentError) { c.instance_exec(c, **kw, &:m) } assert_equal(kw, c.instance_exec(c, kw, **kw, &:m)) assert_equal(h, c.instance_exec(c, **h, &:m)) assert_equal(h, c.instance_exec(c, a: 1, &:m)) @@ -3815,39 +3031,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(h2, c.instance_exec(c, **h2, &:m)) assert_equal(h3, c.instance_exec(c, **h3, &:m)) assert_equal(h3, c.instance_exec(c, a: 1, **h2, &:m)) - assert_warn(/Using the last argument as keyword parameters is deprecated/) do - assert_equal(h, c.instance_exec(c, h, &:m)) - end + assert_raise(ArgumentError) { c.instance_exec(c, h, &:m) } assert_raise(ArgumentError) { c.instance_exec(c, h2, &:m) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do - assert_raise(ArgumentError) { c.instance_exec(c, h3, &:m) } - end + assert_raise(ArgumentError) { c.instance_exec(c, h3, &:m) } c.singleton_class.remove_method(:m) def c.m(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - c.instance_exec(c, **{}, &:m) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - c.instance_exec(c, **kw, &:m) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, kw], c.instance_exec(c, **h, &:m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h, kw], c.instance_exec(c, a: 1, &:m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h2, kw], c.instance_exec(c, **h2, &:m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, kw], c.instance_exec(c, **h3, &:m)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do - assert_equal([h3, kw], c.instance_exec(c, a: 1, **h2, &:m)) - end + assert_raise(ArgumentError) { c.instance_exec(c, **{}, &:m) } + assert_raise(ArgumentError) { c.instance_exec(c, **kw, &:m) } + assert_raise(ArgumentError) { c.instance_exec(c, **h, &:m) } + assert_raise(ArgumentError) { c.instance_exec(c, a: 1, &:m) } + assert_raise(ArgumentError) { c.instance_exec(c, **h2, &:m) } + assert_raise(ArgumentError) { c.instance_exec(c, **h3, &:m) } + assert_raise(ArgumentError) { c.instance_exec(c, a: 1, **h2, &:m) } assert_equal([h, kw], c.instance_exec(c, h, &:m)) assert_equal([h2, kw], c.instance_exec(c, h2, &:m)) assert_equal([h3, kw], c.instance_exec(c, h3, &:m)) @@ -3863,13 +3061,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, h2], c.instance_exec(c, **h2, &:m)) assert_equal([1, h3], c.instance_exec(c, **h3, &:m)) assert_equal([1, h3], c.instance_exec(c, a: 1, **h2, &:m)) - assert_warn(/Using the last argument as keyword parameters is deprecated/m) do - assert_equal([1, h], c.instance_exec(c, h, &:m)) - end + assert_equal([h, kw], c.instance_exec(c, h, &:m)) assert_equal([h2, kw], c.instance_exec(c, h2, &:m)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do - assert_equal([h2, h], c.instance_exec(c, h3, &:m)) - end + assert_equal([h3, kw], c.instance_exec(c, h3, &:m)) end def test_rb_yield_block_kwsplat @@ -3908,12 +3102,8 @@ class TestKeywordArguments < Test::Unit::TestCase def c.c(args) args end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal(kw, c.m(:c, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal(kw, c.m(:c, **kw)) - end + assert_raise(ArgumentError) { c.m(:c, **{}) } + assert_raise(ArgumentError) { c.m(:c, **kw) } assert_equal(kw, c.m(:c, kw, **kw)) assert_equal(h, c.m(:c, **h)) assert_equal(h, c.m(:c, a: 1)) @@ -3933,39 +3123,21 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([h2, h2], c.m(:c, **h2, &m)) assert_equal([h3, h3], c.m(:c, **h3, &m)) assert_equal([h3, h3], c.m(:c, a: 1, **h2, &m)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `c'/m) do - assert_equal([h, h], c.m(:c, h, &m)) - end + assert_raise(ArgumentError) { c.m(:c, h, &m) } assert_raise(ArgumentError) { c.m(:c, h2, &m) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `c'/m) do - assert_raise(ArgumentError) { c.m(:c, h3, &m) } - end + assert_raise(ArgumentError) { c.m(:c, h3, &m) } c.singleton_class.remove_method(:c) def c.c(arg, **args) [arg, args] end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal([kw, kw], c.m(:c, **{})) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal([kw, kw], c.m(:c, **kw)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal([h, kw], c.m(:c, **h)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal([h, kw], c.m(:c, a: 1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal([h2, kw], c.m(:c, **h2)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal([h3, kw], c.m(:c, **h3)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do - assert_equal([h3, kw], c.m(:c, a: 1, **h2)) - end + assert_raise(ArgumentError) { c.m(:c, **{}, &m) } + assert_raise(ArgumentError) { c.m(:c, **kw, &m) } + assert_raise(ArgumentError) { c.m(:c, **h, &m) } + assert_raise(ArgumentError) { c.m(:c, a: 1, &m) } + assert_raise(ArgumentError) { c.m(:c, **h2, &m) } + assert_raise(ArgumentError) { c.m(:c, **h3, &m) } + assert_raise(ArgumentError) { c.m(:c, a: 1, **h2, &m) } assert_equal([h, kw], c.m(:c, h)) assert_equal([h2, kw], c.m(:c, h2)) assert_equal([h3, kw], c.m(:c, h3)) @@ -3981,13 +3153,9 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, h2], c.m(:c, **h2)) assert_equal([1, h3], c.m(:c, **h3)) assert_equal([1, h3], c.m(:c, a: 1, **h2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `c'/m) do - assert_equal([1, h], c.m(:c, h)) - end + assert_equal([h, kw], c.m(:c, h)) assert_equal([h2, kw], c.m(:c, h2)) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `c'/m) do - assert_equal([h2, h], c.m(:c, h3)) - end + assert_equal([h3, kw], c.m(:c, h3)) end def p1 @@ -4115,25 +3283,16 @@ class TestKeywordArguments < Test::Unit::TestCase def test_rest_keyrest bug7665 = '[ruby-core:51278]' bug8463 = '[ruby-core:55203] [Bug #8463]' - expect = [*%w[foo bar], {zzz: 42}] - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `rest_keyrest'/m) do - assert_equal(expect, rest_keyrest(*expect), bug7665) - end + a = [*%w[foo bar], {zzz: 42}] + expect = a + [{}] + assert_equal(expect, rest_keyrest(*a), bug7665) pr = proc {|*args, **opt| next *args, opt} - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(expect, pr.call(*expect), bug7665) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(expect, pr.call(expect), bug8463) - end + assert_equal(expect, pr.call(*a), bug7665) + assert_equal(expect, pr.call(a), bug8463) pr = proc {|a, *b, **opt| next a, *b, opt} - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(expect, pr.call(expect), bug8463) - end + assert_equal(expect, pr.call(a), bug8463) pr = proc {|a, **opt| next a, opt} - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463) - end + assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463) end def req_plus_keyword(x, **h) @@ -4148,16 +3307,10 @@ class TestKeywordArguments < Test::Unit::TestCase [a, h] end - def test_keyword_split - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `req_plus_keyword'/m) do - assert_equal([{:a=>1}, {}], req_plus_keyword(:a=>1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `req_plus_keyword'/m) do - assert_equal([{"a"=>1}, {}], req_plus_keyword("a"=>1)) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `req_plus_keyword'/m) do - assert_equal([{"a"=>1, :a=>1}, {}], req_plus_keyword("a"=>1, :a=>1)) - end + def test_keyword_no_split + assert_raise(ArgumentError) { req_plus_keyword(:a=>1) } + assert_raise(ArgumentError) { req_plus_keyword("a"=>1) } + assert_raise(ArgumentError) { req_plus_keyword("a"=>1, :a=>1) } assert_equal([{:a=>1}, {}], req_plus_keyword({:a=>1})) assert_equal([{"a"=>1}, {}], req_plus_keyword({"a"=>1})) assert_equal([{"a"=>1, :a=>1}, {}], req_plus_keyword({"a"=>1, :a=>1})) @@ -4165,24 +3318,16 @@ 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_warn(/Using the last argument as keyword parameters is deprecated.*The called method `opt_plus_keyword'/m) 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}, {}], opt_plus_keyword({"a"=>1})) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `opt_plus_keyword'/m) do - assert_equal([{"a"=>1}, {:a=>1}], opt_plus_keyword({"a"=>1, :a=>1})) - end + 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_warn(/Using the last argument as keyword parameters is deprecated.*The called method `splat_plus_keyword'/m) do - assert_equal([[], {:a=>1}], splat_plus_keyword({:a=>1})) - end + assert_equal([[{:a=>1}], {}], splat_plus_keyword({:a=>1})) assert_equal([[{"a"=>1}], {}], splat_plus_keyword({"a"=>1})) - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `splat_plus_keyword'/m) do - assert_equal([[{"a"=>1}], {:a=>1}], splat_plus_keyword({"a"=>1, :a=>1})) - end + assert_equal([[{"a"=>1, :a=>1}], {}], splat_plus_keyword({"a"=>1, :a=>1})) end def test_bare_kwrest @@ -4367,9 +3512,7 @@ class TestKeywordArguments < Test::Unit::TestCase [a, b, c, d, e, f, g] end end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `foo'/m) do - assert_equal([1, 2, 1, [], {:f=>5}, 2, {}], a.new.foo(1, 2, f:5), bug8993) - end + assert_raise(ArgumentError) { a.new.foo(1, 2, f:5) } end def test_splat_keyword_nondestructive @@ -4396,18 +3539,12 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal({a: 1, b: 2}, m1(**o, **o2) {|x| break x}, bug9898) end - def test_implicit_hash_conversion - bug10016 = '[ruby-core:63593] [Bug #10016]' - + def test_no_implicit_hash_conversion o = Object.new def o.to_hash() { k: 9 } end assert_equal([1, 42, [], o, :key, {}, nil], f9(1, o)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m1'/m) do - assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m1'/m) do - assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016) - end + assert_equal([1, 0], m1(1, o) {|a, k: 0| break [a, k]}) + assert_raise(ArgumentError) { m1(1, o, &->(a, k: 0) {break [a, k]}) } end def test_splat_hash @@ -4418,7 +3555,7 @@ class TestKeywordArguments < Test::Unit::TestCase def m.f3(**a) a; end def m.f4(*a) a; end o = {a: 1} - assert_raise_with_message(ArgumentError, /unknown keyword: :a/) { + assert_raise_with_message(ArgumentError, /wrong number of arguments \(given 1, expected 0\)/) { m.f(**o) } o = {} @@ -4711,22 +3848,12 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase assert_raise(ArgumentError) { c.call(**h3, &:m) } assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m) } - redef = -> do - c.singleton_class.remove_method(:m) - eval <<-END - def c.m(args) - args - end - END - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.call(**{}, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal(kw, c.call(**kw, &:m)) + c.singleton_class.remove_method(:m) + def c.m(args) + args end + assert_raise(ArgumentError) { c.call(**{}, &:m) } + assert_raise(ArgumentError) { c.call(**kw, &:m) } assert_equal(h, c.call(**h, &:m)) assert_equal(h, c.call(a: 1, &:m)) assert_equal(h2, c.call(**h2, &:m)) @@ -4744,50 +3871,21 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase assert_equal(h2, c.call(**h2, &:m)) assert_equal(h3, c.call(**h3, &:m)) assert_equal(h3, c.call(a: 1, **h2, &:m)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(h, c.call(h, &:m)) - end + assert_raise(ArgumentError) { c.call(h, &:m) } assert_raise(ArgumentError) { c.call(h2, &:m) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `call'/m) do - assert_raise(ArgumentError) { c.call(h3, &:m) } - end + assert_raise(ArgumentError) { c.call(h3, &:m) } - redef = -> do - c.singleton_class.remove_method(:m) - eval <<-END - def c.m(arg, **args) - [arg, args] - end - END - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], c.call(**{}, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([kw, kw], c.call(**kw, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.call(**h, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h, kw], c.call(a: 1, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h2, kw], c.call(**h2, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.call(**h3, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do - assert_equal([h3, kw], c.call(a: 1, **h2, &:m)) + c.singleton_class.remove_method(:m) + def c.m(arg, **args) + [arg, args] end + assert_raise(ArgumentError) { c.call(**{}, &:m) } + assert_raise(ArgumentError) { c.call(**kw, &:m) } + assert_raise(ArgumentError) { c.call(**h, &:m) } + assert_raise(ArgumentError) { c.call(a: 1, &:m) } + assert_raise(ArgumentError) { c.call(**h2, &:m) } + assert_raise(ArgumentError) { c.call(**h3, &:m) } + assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m) } c.singleton_class.remove_method(:m) def c.m(arg=1, **args) @@ -4831,22 +3929,12 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase assert_raise(ArgumentError) { c.call(**h3, &:m) } assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m) } - redef = -> do - c.singleton_class.remove_method(:method_missing) - eval <<-END - def c.method_missing(_, args) - args - end - END - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.call(**{}, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.call(**kw, &:m)) + c.singleton_class.remove_method(:method_missing) + def c.method_missing(_, args) + args end + assert_raise(ArgumentError) { c.call(**{}, &:m) } + assert_raise(ArgumentError) { c.call(**kw, &:m) } assert_equal(h, c.call(**h, &:m)) assert_equal(h, c.call(a: 1, &:m)) assert_equal(h2, c.call(**h2, &:m)) @@ -4864,50 +3952,21 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase assert_equal(h2, c.call(**h2, &:m)) assert_equal(h3, c.call(**h3, &:m)) assert_equal(h3, c.call(a: 1, **h2, &:m)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(h, c.call(h, &:m2)) - end + assert_raise(ArgumentError) { c.call(h, &:m2) } assert_raise(ArgumentError) { c.call(h2, &:m2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `call'/m) do - assert_raise(ArgumentError) { c.call(h3, &:m2) } - end + assert_raise(ArgumentError) { c.call(h3, &:m2) } - redef = -> do - c.singleton_class.remove_method(:method_missing) - eval <<-END - def c.method_missing(_, arg, **args) - [arg, args] - end - END - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.call(**{}, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.call(**kw, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.call(**h, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.call(a: 1, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h2, kw], c.call(**h2, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.call(**h3, &:m)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.call(a: 1, **h2, &:m)) + c.singleton_class.remove_method(:method_missing) + def c.method_missing(_, arg, **args) + [arg, args] end + assert_raise(ArgumentError) { c.call(**{}, &:m2) } + assert_raise(ArgumentError) { c.call(**kw, &:m2) } + assert_raise(ArgumentError) { c.call(**h, &:m2) } + assert_raise(ArgumentError) { c.call(a: 1, &:m2) } + assert_raise(ArgumentError) { c.call(**h2, &:m2) } + assert_raise(ArgumentError) { c.call(**h3, &:m2) } + assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m2) } c.singleton_class.remove_method(:method_missing) def c.method_missing(_, arg=1, **args) @@ -4951,22 +4010,12 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase assert_raise(ArgumentError) { c.call(**h3, &:m2) } assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m2) } - redef = -> do - c.singleton_class.remove_method(:method_missing) - eval <<-END - def c.method_missing(_, args) - args - end - END - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.call(**{}, &:m2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal(kw, c.call(**kw, &:m2)) + c.singleton_class.remove_method(:method_missing) + def c.method_missing(_, args) + args end + assert_raise(ArgumentError) { c.call(**{}, &:m2) } + assert_raise(ArgumentError) { c.call(**kw, &:m2) } assert_equal(h, c.call(**h, &:m2)) assert_equal(h, c.call(a: 1, &:m2)) assert_equal(h2, c.call(**h2, &:m2)) @@ -4984,50 +4033,21 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase assert_equal(h2, c.call(**h2, &:m2)) assert_equal(h3, c.call(**h3, &:m2)) assert_equal(h3, c.call(a: 1, **h2, &:m2)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(h, c.call(h, &:m2)) - end + assert_raise(ArgumentError) { c.call(h, &:m2) } assert_raise(ArgumentError) { c.call(h2, &:m2) } - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `call'/m) do - assert_raise(ArgumentError) { c.call(h3, &:m2) } - end + assert_raise(ArgumentError) { c.call(h3, &:m2) } - redef = -> do - c.singleton_class.remove_method(:method_missing) - eval <<-END - def c.method_missing(_, arg, **args) - [arg, args] - end - END - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.call(**{}, &:m2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([kw, kw], c.call(**kw, &:m2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.call(**h, &:m2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h, kw], c.call(a: 1, &:m2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h2, kw], c.call(**h2, &:m2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.call(**h3, &:m2)) - end - redef[] - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do - assert_equal([h3, kw], c.call(a: 1, **h2, &:m2)) + c.singleton_class.remove_method(:method_missing) + def c.method_missing(_, arg, **args) + [arg, args] end + assert_raise(ArgumentError) { c.call(**{}, &:m2) } + assert_raise(ArgumentError) { c.call(**kw, &:m2) } + assert_raise(ArgumentError) { c.call(**h, &:m2) } + assert_raise(ArgumentError) { c.call(a: 1, &:m2) } + assert_raise(ArgumentError) { c.call(**h2, &:m2) } + assert_raise(ArgumentError) { c.call(**h3, &:m2) } + assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m2) } c.singleton_class.remove_method(:method_missing) def c.method_missing(_, arg=1, **args) diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index f300710d2c..74ea75ee42 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -631,15 +631,16 @@ class TestMarshal < Test::Unit::TestCase def test_no_internal_ids opt = %w[--disable=gems] - args = [opt, 'Marshal.dump("",STDOUT)', true, true, encoding: Encoding::ASCII_8BIT] - out, err, status = EnvUtil.invoke_ruby(*args) + args = [opt, 'Marshal.dump("",STDOUT)', true, true] + kw = {encoding: Encoding::ASCII_8BIT} + out, err, status = EnvUtil.invoke_ruby(*args, **kw) assert_empty(err) assert_predicate(status, :success?) expected = out opt << "--enable=frozen-string-literal" opt << "--debug=frozen-string-literal" - out, err, status = EnvUtil.invoke_ruby(*args) + out, err, status = EnvUtil.invoke_ruby(*args, **kw) assert_empty(err) assert_predicate(status, :success?) assert_equal(expected, out) diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index 636f827fe3..7ea02fdcbf 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -293,12 +293,9 @@ class TestNumeric < Test::Unit::TestCase assert_raise(ArgumentError, bug9811) { 1.step(10, 1, by: 11).size } - e = assert_warn(/Using the last argument as keyword parameters is deprecated/) { - 1.step(10, {by: "1"}) - } - assert_warn('') { - assert_raise(ArgumentError) {e.size} - } + e = 1.step(10, {by: "1"}) + assert_raise(TypeError) {e.next} + assert_raise(TypeError) {e.size} assert_equal(bignum*2+1, (-bignum).step(bignum, 1).size) assert_equal(bignum*2, (-bignum).step(bignum-1, 1).size) diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index fce1bd4a87..af4cf11623 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -1501,29 +1501,15 @@ class TestProcKeywords < Test::Unit::TestCase g = ->(kw) { kw.merge(:a=>2) } assert_equal(2, (f >> g).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (f << g).call(a: 3)[:a]) - end + assert_raise(ArgumentError) { (f << g).call(a: 3)[:a] } assert_equal(2, (f >> g).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (f << g).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(2, (f >> g).call({a: 3})[:a]) - end + assert_raise(ArgumentError) { (f << g).call({a: 3})[:a] } + assert_raise(ArgumentError) { (f >> g).call({a: 3})[:a] } assert_equal(2, (g << f).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (g >> f).call(a: 3)[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(2, (g << f).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (g >> f).call({a: 3})[:a]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (f << g).call(**{})[:a]) - end + assert_raise(ArgumentError) { (g >> f).call(a: 3)[:a] } + assert_raise(ArgumentError) { (g << f).call({a: 3})[:a] } + assert_raise(ArgumentError) { (g >> f).call({a: 3})[:a] } + assert_raise(ArgumentError) { (f << g).call(**{})[:a] } assert_equal(2, (f >> g).call(**{})[:a]) end @@ -1531,29 +1517,15 @@ class TestProcKeywords < Test::Unit::TestCase f = ->(**kw) { kw.merge(:a=>1) }.method(:call) g = ->(kw) { kw.merge(:a=>2) }.method(:call) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (f << g).call(a: 3)[:a]) - end + assert_raise(ArgumentError) { (f << g).call(a: 3)[:a] } assert_equal(2, (f >> g).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (f << g).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(2, (f >> g).call({a: 3})[:a]) - end + assert_raise(ArgumentError) { (f << g).call({a: 3})[:a] } + assert_raise(ArgumentError) { (f >> g).call({a: 3})[:a] } assert_equal(2, (g << f).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (g >> f).call(a: 3)[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(2, (g << f).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (g >> f).call({a: 3})[:a]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (f << g).call(**{})[:a]) - end + assert_raise(ArgumentError) { (g >> f).call(a: 3)[:a] } + assert_raise(ArgumentError) { (g << f).call({a: 3})[:a] } + assert_raise(ArgumentError) { (g >> f).call({a: 3})[:a] } + assert_raise(ArgumentError) { (f << g).call(**{})[:a] } assert_equal(2, (f >> g).call(**{})[:a]) end @@ -1565,29 +1537,15 @@ class TestProcKeywords < Test::Unit::TestCase def g.<<(f) to_proc << f end def g.>>(f) to_proc >> f end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (f << g).call(a: 3)[:a]) - end + assert_raise(ArgumentError) { (f << g).call(a: 3)[:a] } assert_equal(2, (f >> g).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (f << g).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(2, (f >> g).call({a: 3})[:a]) - end + assert_raise(ArgumentError) { (f << g).call({a: 3})[:a] } + assert_raise(ArgumentError) { (f >> g).call({a: 3})[:a] } assert_equal(2, (g << f).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (g >> f).call(a: 3)[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(2, (g << f).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do - assert_equal(1, (g >> f).call({a: 3})[:a]) - end - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `call'/m) do - assert_equal(1, (f << g).call(**{})[:a]) - end + assert_raise(ArgumentError) { (g >> f).call(a: 3)[:a] } + assert_raise(ArgumentError) { (g << f).call({a: 3})[:a] } + assert_raise(ArgumentError) { (g >> f).call({a: 3})[:a] } + assert_raise(ArgumentError) { (f << g).call(**{})[:a] } assert_equal(2, (f >> g).call(**{})[:a]) f = ->(kw) { kw.merge(:a=>1) } @@ -1598,29 +1556,15 @@ class TestProcKeywords < Test::Unit::TestCase def g.>>(f) to_proc >> f end assert_equal(1, (f << g).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(2, (f >> g).call(a: 3)[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(1, (f << g).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(2, (f >> g).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(2, (g << f).call(a: 3)[:a]) - end + assert_raise(ArgumentError) { (f >> g).call(a: 3)[:a] } + assert_raise(ArgumentError) { (f << g).call({a: 3})[:a] } + assert_raise(ArgumentError) { (f >> g).call({a: 3})[:a] } + assert_raise(ArgumentError) { (g << f).call(a: 3)[:a] } assert_equal(1, (g >> f).call(a: 3)[:a]) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(2, (g << f).call({a: 3})[:a]) - end - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(1, (g >> f).call({a: 3})[:a]) - end + assert_raise(ArgumentError) { (g << f).call({a: 3})[:a] } + assert_raise(ArgumentError) { (g >> f).call({a: 3})[:a] } assert_equal(1, (f << g).call(**{})[:a]) - assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do - assert_equal(2, (f >> g).call(**{})[:a]) - end + assert_raise(ArgumentError) { (f >> g).call(**{})[:a] } end end diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index f13afbbdd4..a7deb13a08 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -115,7 +115,7 @@ module TestStruct assert_equal "#{@Struct}::KeywordInitTrue(keyword_init: true)", @Struct::KeywordInitTrue.inspect # eval is needed to prevent the warning duplication filter k = eval("Class.new(@Struct::KeywordInitFalse) {def initialize(**) end}") - assert_warn(/Using the last argument as keyword parameters is deprecated/) {k.new(a: 1, b: 2)} + assert_raise(ArgumentError) { k.new(a: 1, b: 2) } k = Class.new(@Struct::KeywordInitTrue) {def initialize(**) end} assert_warn('') {k.new(a: 1, b: 2)} diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 72f539068d..01f3295101 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -182,9 +182,7 @@ class TestSyntax < Test::Unit::TestCase h = {k3: 31} assert_raise(ArgumentError) {o.kw(**h)} h = {"k1"=>11, k2: 12} - assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `kw'/m) do - assert_raise(ArgumentError) {o.kw(**h)} - end + assert_raise(ArgumentError) {o.kw(**h)} end def test_keyword_duplicated @@ -199,7 +197,7 @@ class TestSyntax < Test::Unit::TestCase assert_equal([1, 2], a, bug10315) a.clear r = nil - assert_warn(/duplicated/) {r = eval("a.f({k: a.add(1), k: a.add(2)})")} + assert_warn(/duplicated/) {r = eval("a.f(**{k: a.add(1), k: a.add(2)})")} assert_equal(2, r) assert_equal([1, 2], a, bug10315) end @@ -1523,12 +1521,12 @@ eom assert_warning('') { assert_equal([[1, 2, 3], {k1: 4, k2: 5}], obj.foo(1, 2, 3, k1: 4, k2: 5)) } - warning = "warning: Using the last argument as keyword parameters is deprecated" - assert_warning(/\A\z|:(?!#{__LINE__+1})\d+: #{warning}/o) { - assert_equal([[], {}], obj.foo({}) {|*x| x}) + array = obj == obj3 ? [] : [{}] + assert_warning('') { + assert_equal([array, {}], obj.foo({}) {|*x| x}) } - assert_warning(/\A\z|:(?!#{__LINE__+1})\d+: #{warning}/o) { - assert_equal([[], {}], obj.foo({})) + assert_warning('') { + assert_equal([array, {}], obj.foo({})) } assert_equal(-1, obj.method(:foo).arity) parameters = obj.method(:foo).parameters diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index aa2675af5d..1437bd8d8c 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -518,15 +518,15 @@ class TestGemRequire < Gem::TestCase define_method "test_no_other_behavioral_changes_with_#{prefix.tr(".", "_")}warn" do lib = File.realpath("../../../lib", __FILE__) Dir.mktmpdir("warn_test") do |dir| - File.write(dir + "/main.rb", "#{prefix}warn({x:1}, {y:2}, [])\n") + File.write(dir + "/main.rb", "warn({x:1}, {y:2}, [])\n") _, err = capture_subprocess_io do - system(@@ruby, "-w", "--disable=gems", "-I", lib, "-C", dir, "main.rb") + system(@@ruby, "-w", "-rpp", "--disable=gems", "-I", lib, "-C", dir, "-I.", "main.rb") end - assert_match(/{:x=>1}\n{:y=>2}\n$/, err) + assert_equal("{:x=>1}\n{:y=>2}\n", err) _, err = capture_subprocess_io do - system(@@ruby, "-w", "--enable=gems", "-I", lib, "-C", dir, "main.rb") + system(@@ruby, "-w", "-rpp", "--enable=gems", "-I", lib, "-C", dir, "-I.", "main.rb") end - assert_match(/{:x=>1}\n{:y=>2}\n$/, err) + assert_equal("{:x=>1}\n{:y=>2}\n", err) end end end diff --git a/test/test_delegate.rb b/test/test_delegate.rb index 02a343358f..303cd16897 100644 --- a/test/test_delegate.rb +++ b/test/test_delegate.rb @@ -190,9 +190,7 @@ class TestDelegateClass < Test::Unit::TestCase assert_equal([], d.bar) assert_equal([[], {:a=>1}], d.foo(:a=>1)) assert_equal([{:a=>1}], d.bar(:a=>1)) - assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `foo'/m) do - assert_equal([[], {:a=>1}], d.foo({:a=>1})) - end + assert_equal([[{:a=>1}], {}], d.foo({:a=>1})) assert_equal([{:a=>1}], d.bar({:a=>1})) end -- cgit v1.2.3