summaryrefslogtreecommitdiff
path: root/test/ruby/test_pattern_matching.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-05-13 15:31:46 -0700
committerJeremy Evans <code@jeremyevans.net>2021-07-15 09:56:02 -0700
commitfa87f72e1e84e2b55516be188f00434a683b924c (patch)
tree0c4efbae462e0ebae46447ea0e18bbea4d7821f0 /test/ruby/test_pattern_matching.rb
parentf1035248af04b2a4d58990740c3f1b840a5eac78 (diff)
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]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4502
Diffstat (limited to 'test/ruby/test_pattern_matching.rb')
-rw-r--r--test/ruby/test_pattern_matching.rb24
1 files changed, 24 insertions, 0 deletions
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