Reword keyword arguments warning messages to convey these are deprecation warnings

This commit is contained in:
Marc-Andre Lafortune 2019-12-23 02:34:16 -05:00
Родитель df6f5c44af
Коммит 819b604037
14 изменённых файлов: 501 добавлений и 501 удалений

Просмотреть файл

@ -2051,7 +2051,7 @@ rb_scan_args_parse(int kw_flag, int argc, const VALUE *argv, const char *fmt, st
if (!keyword_given && !last_hash_keyword) {
/* Warn if treating positional as keyword, as in Ruby 3,
this will be an error */
rb_warn("The last argument is used as keyword parameters");
rb_warn("Using the last argument as keyword parameters is deprecated");
}
argc--;
}
@ -2066,7 +2066,7 @@ rb_scan_args_parse(int kw_flag, int argc, const VALUE *argv, const char *fmt, st
}
else if (arg->f_hash && keyword_given && arg->n_mand == argc) {
/* Warn if treating keywords as positional, as in Ruby 3, this will be an error */
rb_warn("The keyword argument is passed as the last hash parameter");
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
}
}
if (arg->f_hash && arg->n_mand == argc+1 && empty_keyword_given) {
@ -2075,7 +2075,7 @@ rb_scan_args_parse(int kw_flag, int argc, const VALUE *argv, const char *fmt, st
ptr[argc] = rb_hash_new();
argc++;
*(&argv) = ptr;
rb_warn("The keyword argument is passed as the last hash parameter");
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
}
arg->argc = argc;

Просмотреть файл

@ -2569,7 +2569,7 @@ rb_scan_args_set(int argc, const VALUE *argv,
if (!keyword_given) {
/* Warn if treating positional as keyword, as in Ruby 3,
this will be an error */
rb_warn("The last argument is used as keyword parameters");
rb_warn("Using the last argument as keyword parameters is deprecated");
}
argc--;
}
@ -2584,7 +2584,7 @@ rb_scan_args_set(int argc, const VALUE *argv,
}
else if (f_hash && keyword_given && n_mand == argc) {
/* Warn if treating keywords as positional, as in Ruby 3, this will be an error */
rb_warn("The keyword argument is passed as the last hash parameter");
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
}
}
if (f_hash && n_mand > 0 && n_mand == argc+1 && empty_keyword_given) {
@ -2593,7 +2593,7 @@ rb_scan_args_set(int argc, const VALUE *argv,
ptr[argc] = rb_hash_new();
argc++;
*(&argv) = ptr;
rb_warn("The keyword argument is passed as the last hash parameter");
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
}

Просмотреть файл

@ -29,7 +29,7 @@ class TestFuncall < Test::Unit::TestCase
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: The keyword argument is passed as the last hash parameter.*The called method is defined here/m) do
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
@ -53,7 +53,7 @@ class TestFuncall < Test::Unit::TestCase
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: The keyword argument is passed as the last hash parameter.*The called method `baz'/m) do
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
@ -64,11 +64,11 @@ class TestFuncall < Test::Unit::TestCase
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: The last argument is used as keyword parameters.*The called method is defined here/m) do
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: The keyword argument is passed as the last hash parameter/) do
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
end

Просмотреть файл

@ -93,12 +93,12 @@ 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(/The keyword argument is passed as the last hash parameter/) do
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_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(/The keyword argument is passed as the last hash parameter/) do
assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
assert_equal([1, {}, nil], Bug::ScanArgs.lead_hash(**{}))
end
end
@ -120,7 +120,7 @@ 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(/The keyword argument is passed as the last hash parameter/) do
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("a", "b", "c")}
@ -145,7 +145,7 @@ 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(/The keyword argument is passed as the last hash parameter/) do
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_equal([3, "a", ["b", "c"], nil], Bug::ScanArgs.lead_var_hash("a", "b", "c"))
@ -173,7 +173,7 @@ 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(/The keyword argument is passed as the last hash parameter/) do
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_equal([3, "a", "b", ["c"], nil], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c"))
@ -189,7 +189,7 @@ 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(/The keyword argument is passed as the last hash parameter/) do
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("a", "b", "c")}
@ -203,7 +203,7 @@ 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(/The keyword argument is passed as the last hash parameter/) do
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_equal([2, "a", nil, "b", {c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", c: 1))
@ -221,7 +221,7 @@ 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(/The keyword argument is passed as the last hash parameter/) do
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_equal([3, ["a", "b"], "c", nil], Bug::ScanArgs.var_trail_hash("a", "b", "c"))
@ -235,7 +235,7 @@ class TestScanArgs < Test::Unit::TestCase
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(/The keyword argument is passed as the last hash parameter/) do
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_equal([2, "a", [], "b", nil], Bug::ScanArgs.lead_var_trail_hash("a", "b"))
@ -250,7 +250,7 @@ class TestScanArgs < Test::Unit::TestCase
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(/The keyword argument is passed as the last hash parameter/) do
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_equal([1, nil, [], "a", {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", c: 1))
@ -266,7 +266,7 @@ class TestScanArgs < Test::Unit::TestCase
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(/The keyword argument is passed as the last hash parameter/) do
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_equal([2, "a", nil, [], "b", nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b"))
@ -285,7 +285,7 @@ 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(/The keyword argument is passed as the last hash parameter/) do
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
@ -294,7 +294,7 @@ class TestScanArgs < Test::Unit::TestCase
end
def test_e_lead_opt_hash
assert_warn(/The keyword argument is passed as the last hash parameter/) do
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"))

Просмотреть файл

@ -1208,7 +1208,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: The last argument is used as keyword parameters; maybe ** should be added to the call\n", warning[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])
warning = capture_warning_warn {warn("test warning", **{uplevel: 0})}
assert_equal("#{__FILE__}:#{__LINE__-1}: warning: test warning\n", warning[0])

Просмотреть файл

@ -2284,7 +2284,7 @@ class TestIO < Test::Unit::TestCase
def o.to_open(**kw); kw; end
assert_equal({:a=>1}, open(o, a: 1))
w = /The last argument is used as keyword parameters.*The called method `(to_)?open'/m
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)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -293,7 +293,7 @@ class TestNumeric < Test::Unit::TestCase
assert_raise(ArgumentError, bug9811) { 1.step(10, 1, by: 11).size }
e = assert_warn(/The last argument is used as keyword parameters/) {
e = assert_warn(/Using the last argument as keyword parameters is deprecated/) {
1.step(10, {by: "1"})
}
assert_warn('') {

Просмотреть файл

@ -1485,27 +1485,27 @@ class TestProcKeywords < Test::Unit::TestCase
g = ->(kw) { kw.merge(:a=>2) }
assert_equal(2, (f >> g).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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_equal(2, (f >> g).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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_equal(2, (g << f).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The keyword argument is passed as the last hash parameter.*The last argument is used as keyword parameters.*The called method is defined here/m) do
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_equal(2, (f >> g).call(**{})[:a])
@ -1515,27 +1515,27 @@ class TestProcKeywords < Test::Unit::TestCase
f = ->(**kw) { kw.merge(:a=>1) }.method(:call)
g = ->(kw) { kw.merge(:a=>2) }.method(:call)
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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_equal(2, (f >> g).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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_equal(2, (g << f).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The keyword argument is passed as the last hash parameter.*The last argument is used as keyword parameters.*The called method is defined here/m) do
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_equal(2, (f >> g).call(**{})[:a])
@ -1549,27 +1549,27 @@ class TestProcKeywords < Test::Unit::TestCase
def g.<<(f) to_proc << f end
def g.>>(f) to_proc >> f end
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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_equal(2, (f >> g).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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_equal(2, (g << f).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The last argument is used as keyword parameters.*The called method is defined here/m) do
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(/The keyword argument is passed as the last hash parameter.*The called method `call'/m) do
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_equal(2, (f >> g).call(**{})[:a])
@ -1582,27 +1582,27 @@ class TestProcKeywords < Test::Unit::TestCase
def g.>>(f) to_proc >> f end
assert_equal(1, (f << g).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method `call'/m) do
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(/The last argument is used as keyword parameters.*The called method `call'/m) do
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(/The last argument is used as keyword parameters.*The called method `call'/m) do
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(/The last argument is used as keyword parameters.*The called method `call'/m) do
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_equal(1, (g >> f).call(a: 3)[:a])
assert_warn(/The last argument is used as keyword parameters.*The called method `call'/m) do
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(/The last argument is used as keyword parameters.*The called method `call'/m) do
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_equal(1, (f << g).call(**{})[:a])
assert_warn(/The keyword argument is passed as the last hash parameter.*The last argument is used as keyword parameters.*The called method `call'/m) do
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
end

Просмотреть файл

@ -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(/The last argument is used as keyword parameters/) {k.new(a: 1, b: 2)}
assert_warn(/Using the last argument as keyword parameters is deprecated/) {k.new(a: 1, b: 2)}
k = Class.new(@Struct::KeywordInitTrue) {def initialize(**) end}
assert_warn('') {k.new(a: 1, b: 2)}

Просмотреть файл

@ -182,7 +182,7 @@ class TestSyntax < Test::Unit::TestCase
h = {k3: 31}
assert_raise(ArgumentError) {o.kw(**h)}
h = {"k1"=>11, k2: 12}
assert_warn(/The last argument is split into positional and keyword parameters.*The called method `kw'/m) do
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
end
@ -1523,7 +1523,7 @@ eom
assert_warning('') {
assert_equal([[1, 2, 3], {k1: 4, k2: 5}], obj.foo(1, 2, 3, k1: 4, k2: 5))
}
warning = "warning: The last argument is used as keyword parameters"
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})
}

Просмотреть файл

@ -190,7 +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(/The last argument is used as keyword parameters.*The called method `foo'/m) do
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.bar({:a=>1}))

Просмотреть файл

@ -645,17 +645,17 @@ rb_warn_keyword_to_last_hash(rb_execution_context_t * const ec, struct rb_callin
VALUE name, loc;
if (calling->recv == Qundef) {
rb_warn("The keyword argument is passed as the last hash parameter");
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
return;
}
name = rb_id2str(ci->mid);
loc = rb_iseq_location(iseq);
if (NIL_P(loc)) {
rb_warn("The keyword argument for `%"PRIsVALUE"' is passed as the last hash parameter",
rb_warn("Passing the keyword argument for `%"PRIsVALUE"' as the last hash parameter is deprecated",
name);
}
else {
rb_warn("The keyword argument is passed as the last hash parameter");
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
if (name) {
rb_compile_warn(RSTRING_PTR(RARRAY_AREF(loc, 0)), FIX2INT(RARRAY_AREF(loc, 1)),
"The called method `%"PRIsVALUE"' is defined here", name);
@ -676,11 +676,11 @@ rb_warn_split_last_hash_to_keyword(rb_execution_context_t * const ec, struct rb_
name = rb_id2str(ci->mid);
loc = rb_iseq_location(iseq);
if (NIL_P(loc)) {
rb_warn("The last argument for `%"PRIsVALUE"' is split into positional and keyword parameters",
rb_warn("Splitting the last argument for `%"PRIsVALUE"' into positional and keyword parameters is deprecated",
name);
}
else {
rb_warn("The last argument is split into positional and keyword parameters");
rb_warn("Splitting the last argument into positional and keyword parameters is deprecated");
if (calling->recv != Qundef) {
rb_compile_warn(RSTRING_PTR(RARRAY_AREF(loc, 0)), FIX2INT(RARRAY_AREF(loc, 1)),
"The called method `%"PRIsVALUE"' is defined here", name);
@ -701,11 +701,11 @@ rb_warn_last_hash_to_keyword(rb_execution_context_t * const ec, struct rb_callin
name = rb_id2str(ci->mid);
loc = rb_iseq_location(iseq);
if (NIL_P(loc)) {
rb_warn("The last argument for `%"PRIsVALUE"' is used as keyword parameters; maybe ** should be added to the call",
rb_warn("Using the last argument for `%"PRIsVALUE"' as keyword parameters is deprecated; maybe ** should be added to the call",
name);
}
else {
rb_warn("The last argument is used as keyword parameters; maybe ** should be added to the call");
rb_warn("Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call");
if (calling->recv != Qundef) {
rb_compile_warn(RSTRING_PTR(RARRAY_AREF(loc, 0)), FIX2INT(RARRAY_AREF(loc, 1)),
"The called method `%"PRIsVALUE"' is defined here", name);

Просмотреть файл

@ -145,7 +145,7 @@ vm_call0_body(rb_execution_context_t *ec, struct rb_calling_info *calling, struc
RB_TYPE_P(argv[calling->argc-1], T_HASH) &&
RHASH_EMPTY_P(argv[calling->argc-1])) {
if (calling->argc == 1) {
rb_warn("The keyword argument is passed as the last hash parameter");
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
}
else {
calling->argc--;