summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_syntax.rb17
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