aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-09-28 12:27:04 -0400
committerKevin Newton <kddnewton@gmail.com>2023-09-28 15:13:09 -0400
commit41d3e23582b3030a652919ee10fda114d7eb5626 (patch)
treee6f7a429125d9474a9ef889cba6175bf163bff7b /test
parent64da9be3af4f7dbeb276df0168b70bdb52af7c4f (diff)
downloadruby-41d3e23582b3030a652919ee10fda114d7eb5626.tar.gz
Support the AlternationPatternNode
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_compile_prism.rb24
1 files changed, 18 insertions, 6 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index c74ecfef8c..d3fdfd68f1 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -338,6 +338,13 @@ module Prism
# Pattern matching #
############################################################################
+ def test_AlternationPatternNode
+ test_prism_eval("1 in 1 | 2")
+ test_prism_eval("1 in 2 | 1")
+ test_prism_eval("1 in 2 | 3 | 4 | 1")
+ test_prism_eval("1 in 2 | 3")
+ end
+
def test_MatchPredicateNode
test_prism_eval("1 in 1")
test_prism_eval("1.0 in 1.0")
@@ -355,11 +362,6 @@ module Prism
test_prism_eval("5 in 0..10")
test_prism_eval("5 in 0...10")
- test_prism_eval("module Prism; @@prism = 1; 1 in ^@@prism; end")
- test_prism_eval("module Prism; @prism = 1; 1 in ^@prism; end")
- test_prism_eval("$prism = 1; 1 in ^$prism")
- test_prism_eval("prism = 1; 1 in ^prism")
-
test_prism_eval("[\"5\"] in %w[5]")
test_prism_eval("Prism in Prism")
@@ -370,11 +372,21 @@ module Prism
test_prism_eval("\"foo\" in /.../")
test_prism_eval("\"foo1\" in /...\#{1}/")
test_prism_eval("4 in ->(v) { v.even? }")
- test_prism_eval("4 in ^(4)")
test_prism_eval("1 in 2")
end
+ def test_PinnedExpressionNode
+ test_prism_eval("4 in ^(4)")
+ end
+
+ def test_PinnedVariableNode
+ test_prism_eval("module Prism; @@prism = 1; 1 in ^@@prism; end")
+ test_prism_eval("module Prism; @prism = 1; 1 in ^@prism; end")
+ test_prism_eval("$prism = 1; 1 in ^$prism")
+ test_prism_eval("prism = 1; 1 in ^prism")
+ end
+
private
def compare_eval(source)