diff options
-rw-r--r-- | bootstraptest/test_insns.rb | 19 | ||||
-rw-r--r-- | test/csv/interface/test_read.rb | 14 | ||||
-rw-r--r-- | test/csv/interface/test_write.rb | 8 | ||||
-rw-r--r-- | test/ruby/test_keyword.rb | 44 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 4 |
5 files changed, 64 insertions, 25 deletions
diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb index 73a9d501f1..2b0f2584c5 100644 --- a/bootstraptest/test_insns.rb +++ b/bootstraptest/test_insns.rb @@ -414,10 +414,25 @@ tests = [ ] # normal path -tests.compact.each {|(insn, expr, *a)| assert_equal 'true', expr, insn, *a } +tests.compact.each do |(insn, expr, *a)| + if a.last.is_a?(Hash) + a = a.dup + kw = a.pop + assert_equal 'true', expr, insn, *a, **kw + else + assert_equal 'true', expr, insn, *a + end +end + # with trace tests.compact.each {|(insn, expr, *a)| progn = "set_trace_func(proc{})\n" + expr - assert_equal 'true', progn, 'trace_' + insn, *a + if a.last.is_a?(Hash) + a = a.dup + kw = a.pop + assert_equal 'true', progn, 'trace_' + insn, *a, **kw + else + assert_equal 'true', progn, 'trace_' + insn, *a + end } diff --git a/test/csv/interface/test_read.rb b/test/csv/interface/test_read.rb index 52620964c0..58ec188f94 100644 --- a/test/csv/interface/test_read.rb +++ b/test/csv/interface/test_read.rb @@ -266,12 +266,12 @@ class TestCSVInterfaceRead < Test::Unit::TestCase def test_options_not_modified options = {}.freeze - CSV.foreach(@input.path, options) - CSV.open(@input.path, options) {} - CSV.parse("", options) - CSV.parse_line("", options) - CSV.read(@input.path, options) - CSV.readlines(@input.path, options) - CSV.table(@input.path, options) + CSV.foreach(@input.path, **options) + CSV.open(@input.path, **options) {} + CSV.parse("", **options) + CSV.parse_line("", **options) + CSV.read(@input.path, **options) + CSV.readlines(@input.path, **options) + CSV.table(@input.path, **options) end end diff --git a/test/csv/interface/test_write.rb b/test/csv/interface/test_write.rb index 8511204ef0..8650ecd624 100644 --- a/test/csv/interface/test_write.rb +++ b/test/csv/interface/test_write.rb @@ -166,9 +166,9 @@ b|a|c def test_options_not_modified options = {}.freeze - CSV.generate(options) {} - CSV.generate_line([], options) - CSV.filter("", "", options) - CSV.instance("", options) + CSV.generate(**options) {} + CSV.generate_line([], **options) + CSV.filter("", "", **options) + CSV.instance("", **options) end end diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 1e707170fd..4361b14f91 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -302,14 +302,24 @@ class TestKeywordArguments < Test::Unit::TestCase bug7665 = '[ruby-core:51278]' bug8463 = '[ruby-core:55203] [Bug #8463]' expect = [*%w[foo bar], {zzz: 42}] - assert_equal(expect, rest_keyrest(*expect), bug7665) + assert_warn(/The last argument for `rest_keyrest' .* is used as the keyword parameter/) do + assert_equal(expect, rest_keyrest(*expect), bug7665) + end pr = proc {|*args, **opt| next *args, opt} - assert_equal(expect, pr.call(*expect), bug7665) - assert_equal(expect, pr.call(expect), bug8463) + assert_warn(/The last argument for `call' is used as the keyword parameter/) do + assert_equal(expect, pr.call(*expect), bug7665) + end + assert_warn(/The last argument for `call' is used as the keyword parameter/) do + assert_equal(expect, pr.call(expect), bug8463) + end pr = proc {|a, *b, **opt| next a, *b, opt} - assert_equal(expect, pr.call(expect), bug8463) + assert_warn(/The last argument for `call' is used as the keyword parameter/) do + assert_equal(expect, pr.call(expect), bug8463) + end pr = proc {|a, **opt| next a, opt} - assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463) + assert_warn(/The last argument for `call' is used as the keyword parameter/) do + assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463) + end end def opt_plus_keyword(x=1, **h) @@ -324,16 +334,24 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([1, {:a=>1}], opt_plus_keyword(:a=>1)) assert_equal([1, {"a"=>1}], opt_plus_keyword("a"=>1)) assert_equal([1, {"a"=>1, :a=>1}], opt_plus_keyword("a"=>1, :a=>1)) - assert_equal([1, {:a=>1}], opt_plus_keyword({:a=>1})) + assert_warn(/The last argument for `opt_plus_keyword' .* is used as the keyword parameter/) do + assert_equal([1, {:a=>1}], opt_plus_keyword({:a=>1})) + end assert_equal([{"a"=>1}, {}], opt_plus_keyword({"a"=>1})) - assert_equal([{"a"=>1}, {:a=>1}], opt_plus_keyword({"a"=>1, :a=>1})) + assert_warn(/The last argument for `opt_plus_keyword' .* is split into positional and keyword parameters/) do + assert_equal([{"a"=>1}, {:a=>1}], opt_plus_keyword({"a"=>1, :a=>1})) + end assert_equal([[], {:a=>1}], splat_plus_keyword(:a=>1)) assert_equal([[], {"a"=>1}], splat_plus_keyword("a"=>1)) assert_equal([[], {"a"=>1, :a=>1}], splat_plus_keyword("a"=>1, :a=>1)) - assert_equal([[], {:a=>1}], splat_plus_keyword({:a=>1})) + assert_warn(/The last argument for `splat_plus_keyword' .* is used as the keyword parameter/) do + assert_equal([[], {:a=>1}], splat_plus_keyword({:a=>1})) + end assert_equal([[{"a"=>1}], {}], splat_plus_keyword({"a"=>1})) - assert_equal([[{"a"=>1}], {:a=>1}], splat_plus_keyword({"a"=>1, :a=>1})) + assert_warn(/The last argument for `splat_plus_keyword' .* is split into positional and keyword parameters/) do + assert_equal([[{"a"=>1}], {:a=>1}], splat_plus_keyword({"a"=>1, :a=>1})) + end end def test_bare_kwrest @@ -551,8 +569,12 @@ class TestKeywordArguments < Test::Unit::TestCase o = Object.new def o.to_hash() { k: 9 } end assert_equal([1, 42, [], o, :key, {}, nil], f9(1, o)) - assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016) - assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016) + assert_warn(/The last argument for `m1' .* is used as the keyword parameter/) do + assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016) + end + assert_warn(/The last argument for `m1' .* is used as the keyword parameter/) do + assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016) + end end def test_splat_hash diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 72a3cc2fc7..85ff68ec25 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -155,7 +155,9 @@ class TestSyntax < Test::Unit::TestCase h = {k3: 31} assert_raise(ArgumentError) {o.kw(**h)} h = {"k1"=>11, k2: 12} - assert_raise(ArgumentError) {o.kw(**h)} + assert_warn(/The last argument for `kw' .* is split into positional and keyword parameters/) do + assert_raise(ArgumentError) {o.kw(**h)} + end end def test_keyword_duplicated |