Unverified Commit de176d37 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4749 from shuujii/add-tests-for-4746

Add tests for #4746
parents 3d278131 882bc80d
......@@ -451,6 +451,18 @@ assert('optional block argument in the rhs default expressions') do
assert_nil(Proc.new {|foo = foo| foo}.call)
end
assert('local variable definition in default value and subsequent arguments') do
def m(a = b = 1, c) [a, b, c] end
assert_equal([1, 1, :c], m(:c))
assert_equal([:a, nil, :c], m(:a, :c))
def m(a = b = 1, &c) [a, b, c ? true : nil] end
assert_equal([1, 1, nil], m)
assert_equal([1, 1, true], m{})
assert_equal([:a, nil, nil], m(:a))
assert_equal([:a, nil, true], m(:a){})
end
assert('multiline comments work correctly') do
=begin
this is a comment with nothing after begin and end
......@@ -654,4 +666,8 @@ assert 'keyword arguments' do
result = m(1, 2, e: 3, g: 4, h: 5, i: 6, &(l = ->{}))
assert_equal([1, 1, [], 2, 3, 2, 4, { h: 5, i: 6 }, l], result)
=end
def m(a: b = 1, c:) [a, b, c] end
assert_equal([1, 1, :c], m(c: :c))
assert_equal([:a, nil, :c], m(a: :a, c: :c))
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment