summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_keyword.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index 5ddcfd892a..506db345b0 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -1238,6 +1238,28 @@ 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))
+
+ c = Object.new
+ class << c
+ define_method(:m) {|*args, **opt| [args, opt] }
+ end
+ assert_warn(/The last argument is used as the keyword parameter.*for method/m) do
+ assert_equal([[], h], c.m(h))
+ end
+ assert_warn(/The last argument is used as the keyword parameter.*for method/m) do
+ assert_equal([[h], h], c.m(h, h))
+ end
+
+ c = Object.new
+ class << c
+ define_method(:m) {|arg=nil, a: nil| [arg, a] }
+ end
+ assert_warn(/The last argument is split into positional and keyword parameters.*for method/m) do
+ assert_equal([h2, 1], c.m(h3))
+ end
+ assert_warn(/The last argument is split into positional and keyword parameters.*for method/m) do
+ assert_equal([h2, 1], c.m(**h3))
+ end
end
def test_attr_reader_kwsplat