summaryrefslogtreecommitdiff
path: root/test/ruby/test_pattern_matching.rb
diff options
context:
space:
mode:
authorKazuki Tsujimoto <[email protected]>2021-03-21 15:12:54 +0900
committerKazuki Tsujimoto <[email protected]>2021-03-21 15:14:31 +0900
commit21863470d965b8cc299b1f82417c70d5d26f8ab2 (patch)
tree727faf202cf818d796602b526e17fb9bfea0cb29 /test/ruby/test_pattern_matching.rb
parent232433f22423fb6a3ff7a610140c711a964d3b3d (diff)
Pattern matching pin operator against expression [Feature #17411]
This commit is based on the patch by @nobu.
Diffstat (limited to 'test/ruby/test_pattern_matching.rb')
-rw-r--r--test/ruby/test_pattern_matching.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb
index b18ef68316..c494550574 100644
--- a/test/ruby/test_pattern_matching.rb
+++ b/test/ruby/test_pattern_matching.rb
@@ -402,6 +402,29 @@ END
end
end
+ def test_pin_operator_expr_pattern
+ assert_block do
+ case 'abc'
+ in ^(/a/)
+ true
+ end
+ end
+
+ assert_block do
+ case {name: '2.6', released_at: Time.new(2018, 12, 25)}
+ in {released_at: ^(Time.new(2010)..Time.new(2020))}
+ true
+ end
+ end
+
+ assert_block do
+ case 0
+ in ^(0+0)
+ true
+ end
+ end
+ end
+
def test_array_pattern
assert_block do
[[0], C.new([0])].all? do |i|