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]
This commit is contained in:
Jeremy Evans 2021-05-13 15:31:46 -07:00
parent f1035248af
commit fa87f72e1e
Notes: git 2021-07-16 01:56:27 +09:00
5 changed files with 79 additions and 2 deletions

View file

@ -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