diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-10-25 00:56:27 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-10-25 00:56:27 +0900 |
commit | ed65e2d5ae700afe8408836a8774becf5c87f76b (patch) | |
tree | 159e87f7d25d8a48e0c7c0e18f251252afc5aba4 /test | |
parent | 8d0c5eb805a0a9afeb6e87c939c9b6f7f22df013 (diff) | |
download | ruby-ed65e2d5ae700afe8408836a8774becf5c87f76b.tar.gz |
Assert no-block case
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_syntax.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 4d00f9169b..aa6e9d57dc 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1491,13 +1491,21 @@ eom obj1 = Object.new def obj1.bar(*args, **kws, &block) - block.call(args, kws) + if block + block.call(args, kws) + else + [args, kws] + end end obj1.instance_eval('def foo(...) bar(...) end', __FILE__, __LINE__) klass = Class.new { def foo(*args, **kws, &block) - block.call(args, kws) + if block + block.call(args, kws) + else + [args, kws] + end end } obj2 = klass.new @@ -1505,6 +1513,7 @@ eom [obj1, obj2].each do |obj| assert_equal([[1, 2, 3], {k1: 4, k2: 5}], obj.foo(1, 2, 3, k1: 4, k2: 5) {|*x| x}) + assert_equal([[1, 2, 3], {k1: 4, k2: 5}], obj.foo(1, 2, 3, k1: 4, k2: 5)) assert_equal(-1, obj.:foo.arity) parameters = obj.:foo.parameters assert_equal(:rest, parameters.dig(0, 0)) |