Skip to content

Commit

Permalink
Add tests for [Feature #19134]
Browse files Browse the repository at this point in the history
  • Loading branch information
shugo committed Nov 29, 2022
1 parent 4db429d commit 74bdf09
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/ruby/test_syntax.rb
Expand Up @@ -183,8 +183,21 @@ def deconstruct(...); [args(*), kw(**), block(&)&.call] end
assert_equal([[1, 2], {}, nil], deconstruct(1, 2))
assert_equal([[], {x: 1}, nil], deconstruct(x: 1))
assert_equal([[], {x: 1, y: 2}, nil], deconstruct(x: 1, y: 2))
assert_equal([[], {}, "x"], deconstruct { "x" })
assert_equal([[1, 2], {x: 3, y: 4}, "x"], deconstruct(1, 2, x: 3, y: 4) { "x" })
assert_equal([[], {}, 1], deconstruct { 1 })
assert_equal([[1, 2], {x: 3, y: 4}, 5], deconstruct(1, 2, x: 3, y: 4) { 5 })
end;

assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}")
begin;
def deconstruct(*args, **kw, &block); [args, kw, block&.call] end
def deconstruct2(*, **, &); deconstruct(...); end
assert_equal([[], {}, nil], deconstruct2)
assert_equal([[1], {}, nil], deconstruct2(1))
assert_equal([[1, 2], {}, nil], deconstruct2(1, 2))
assert_equal([[], {x: 1}, nil], deconstruct2(x: 1))
assert_equal([[], {x: 1, y: 2}, nil], deconstruct2(x: 1, y: 2))
assert_equal([[], {}, 1], deconstruct2 { 1 })
assert_equal([[1, 2], {x: 3, y: 4}, 5], deconstruct2(1, 2, x: 3, y: 4) { 5 })
end;
end

Expand Down

0 comments on commit 74bdf09

Please sign in to comment.