summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-08-20 12:29:51 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-30 12:39:31 -0700
commit856bb3c35d5d81481b2e5dd00353298e8a0c2ee7 (patch)
tree02844dc2808b315f85ecf71f460e2d49e43d53d4 /test
parent42adc5bc6bb532e20bf2191ad99781ee701dea36 (diff)
Fix remaining warning issues in the tests due to keyword argument separation
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2395
Diffstat (limited to 'test')
-rw-r--r--test/csv/interface/test_read.rb14
-rw-r--r--test/csv/interface/test_write.rb8
-rw-r--r--test/ruby/test_keyword.rb44
-rw-r--r--test/ruby/test_syntax.rb4
4 files changed, 47 insertions, 23 deletions
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