summaryrefslogtreecommitdiffhomepage
path: root/test/t
diff options
context:
space:
mode:
authorcremno <[email protected]>2015-06-22 13:34:24 +0200
committercremno <[email protected]>2015-06-22 13:34:24 +0200
commitf0eaf9eaf53ce659c44ce6beeedbeb8bfc5b4efa (patch)
tree24157e0c89c1fce3e85335d513e1323f4743c490 /test/t
parente344c6ab6d7b3d6a8ffcec6f7f96aeba6c5fdeda (diff)
downloadmruby-f0eaf9eaf53ce659c44ce6beeedbeb8bfc5b4efa.tar.gz
mruby-f0eaf9eaf53ce659c44ce6beeedbeb8bfc5b4efa.zip
fix arity of lambdas with optional arguments
From the CRuby 2.2.2 Proc#arity documentation: If the block has optional arguments, returns -n-1, where n is the number of mandatory arguments, with the exception for blocks that are not lambdas and have only a finite number of optional arguments; in this latter case, returns n.
Diffstat (limited to 'test/t')
-rw-r--r--test/t/proc.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/t/proc.rb b/test/t/proc.rb
index 22ccceb68..888b7d56a 100644
--- a/test/t/proc.rb
+++ b/test/t/proc.rb
@@ -36,6 +36,14 @@ assert('Proc#arity', '15.2.17.4.2') do
assert_equal(-3, b)
assert_equal 1, c
assert_equal 1, d
+
+ e = ->(x=0, y){}.arity
+ f = ->((x, y), z=0){}.arity
+ g = ->(x=0){}.arity
+
+ assert_equal(-2, e)
+ assert_equal(-2, f)
+ assert_equal(-1, g)
end
assert('Proc#call', '15.2.17.4.3') do