summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-12-09 11:56:54 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-12-09 11:56:54 +0900
commit092dd4a667175a123ef9b628e7008be6398d7e0e (patch)
tree6a7ef006e884da9622509620295a061d777d2b00 /test
parent2e9b8f0d9bf835093338dec197c8003651705a21 (diff)
downloadmruby-092dd4a667175a123ef9b628e7008be6398d7e0e.tar.gz
mruby-092dd4a667175a123ef9b628e7008be6398d7e0e.zip
Argument forwarding with `...` now supports leading arguments.
```ruby def method_missing(meth, ...) send(:"do_#{meth}", ...) end ```
Diffstat (limited to 'test')
-rw-r--r--test/t/syntax.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb
index ae698c385..3b6de6c18 100644
--- a/test/t/syntax.rb
+++ b/test/t/syntax.rb
@@ -686,3 +686,22 @@ assert('_0 is not numbered parameter') do
_0 = :l
assert_equal(:l, ->{_0}.call)
end
+
+assert('argument forwarding') do
+ c = Class.new {
+ def a0(*a,&b)
+ assert_equal([1,2,3], a)
+ assert_not_nil(b)
+ end
+ def a(...)
+ a0(...)
+ end
+ def b(a,...)
+ assert_equal(a,1)
+ a0(1,...)
+ end
+ }
+ o = c.new
+ o.a(1,2,3){}
+ o.b(1,2,3){}
+end