From 21863470d965b8cc299b1f82417c70d5d26f8ab2 Mon Sep 17 00:00:00 2001 From: Kazuki Tsujimoto Date: Sun, 21 Mar 2021 15:12:54 +0900 Subject: Pattern matching pin operator against expression [Feature #17411] This commit is based on the patch by @nobu. --- test/ruby/test_pattern_matching.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/ruby/test_pattern_matching.rb') 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| -- cgit v1.2.3