From fa87f72e1e84e2b55516be188f00434a683b924c Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 13 May 2021 15:31:46 -0700 Subject: Add pattern matching pin support for instance/class/global variables Pin matching for local variables and constants is already supported, and it is fairly simple to add support for these variable types. Note that pin matching for method calls is still not supported without wrapping in parentheses (pin expressions). I think that's for the best as method calls are far more complex (arguments/blocks). Implements [Feature #17724] --- test/ruby/test_pattern_matching.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 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 c494550574..320c2c00c7 100644 --- a/test/ruby/test_pattern_matching.rb +++ b/test/ruby/test_pattern_matching.rb @@ -400,6 +400,30 @@ END a == 0 end end + + assert_block do + @a = /a/ + case 'abc' + in ^@a + true + end + end + + assert_block do + @@TestPatternMatching = /a/ + case 'abc' + in ^@@TestPatternMatching + true + end + end + + assert_block do + $TestPatternMatching = /a/ + case 'abc' + in ^$TestPatternMatching + true + end + end end def test_pin_operator_expr_pattern -- cgit v1.2.3