summaryrefslogtreecommitdiff
path: root/test/ruby/test_keyword.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r--test/ruby/test_keyword.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index 0bdcb79c6d..c8191a722c 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -2411,6 +2411,13 @@ class TestKeywordArguments < Test::Unit::TestCase
args
end
+ def empty_method
+ end
+
+ def opt(arg = :opt)
+ arg
+ end
+
ruby2_keywords def foo_dbar(*args)
dbar(*args)
end
@@ -2419,6 +2426,16 @@ class TestKeywordArguments < Test::Unit::TestCase
dbaz(*args)
end
+ ruby2_keywords def clear_last_empty_method(*args)
+ args.last.clear
+ empty_method(*args)
+ end
+
+ ruby2_keywords def clear_last_opt(*args)
+ args.last.clear
+ opt(*args)
+ end
+
define_method(:dbar) do |*args, **kw|
[args, kw]
end
@@ -2653,6 +2670,9 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal([[1, h1], {}], o.foo(:pass_bar, 1, :a=>1))
assert_equal([[1, h1], {}], o.foo(:pass_cfunc, 1, :a=>1))
+ assert_equal(:opt, o.clear_last_opt(a: 1))
+ assert_nothing_raised(ArgumentError) { o.clear_last_empty_method(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))
end