diff options
author | Shugo Maeda <shugo@ruby-lang.org> | 2022-11-29 14:17:03 +0900 |
---|---|---|
committer | Shugo Maeda <shugo@ruby-lang.org> | 2022-11-29 14:18:16 +0900 |
commit | 74bdf09215da3c9f1eb31feea3666359acbce527 (patch) | |
tree | b12300d69cab5070bae0a466ebf26dd4639cc616 /test/ruby | |
parent | 4db429d211aaada1829a6b4a6d672c77b97687a1 (diff) | |
download | ruby-74bdf09215da3c9f1eb31feea3666359acbce527.tar.gz |
Add tests for [Feature #19134]
https://bugs.ruby-lang.org/issues/19134?next_issue_id=19133&prev_issue_id=19135#note-4
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_syntax.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index a5106e0353..6695e46b92 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -183,8 +183,21 @@ class TestSyntax < Test::Unit::TestCase 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 |