Skip to content

Commit

Permalink
Import whitequark find pattern tests
Browse files Browse the repository at this point in the history
Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
  • Loading branch information
vinistock and Morriar committed Jul 14, 2021
1 parent 2953c69 commit 9b353db
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 2 deletions.
12 changes: 12 additions & 0 deletions test/whitequark/test_find_pattern_0.parse-tree-whitequark.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
s(:case_match,
s(:lvar, :foo),
s(:in_pattern,
s(:find_pattern,
s(:match_rest,
s(:match_var, :x)),
s(:match_as,
s(:int, "1"),
s(:match_var, :a)),
s(:match_rest,
s(:match_var, :y))), nil,
s(:true)), nil)
3 changes: 3 additions & 0 deletions test/whitequark/test_find_pattern_0.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typed: true

case foo; in [*x, 1 => a, *y] then true; end
10 changes: 10 additions & 0 deletions test/whitequark/test_find_pattern_1.parse-tree-whitequark.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
s(:case_match,
s(:lvar, :foo),
s(:in_pattern,
s(:const_pattern,
s(:const, nil, :String),
s(:find_pattern,
s(:match_rest, nil),
s(:int, "1"),
s(:match_rest, nil))), nil,
s(:true)), nil)
3 changes: 3 additions & 0 deletions test/whitequark/test_find_pattern_1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typed: true

case foo; in String(*, 1, *) then true; end
10 changes: 10 additions & 0 deletions test/whitequark/test_find_pattern_2.parse-tree-whitequark.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
s(:case_match,
s(:lvar, :foo),
s(:in_pattern,
s(:const_pattern,
s(:const, nil, :Array),
s(:find_pattern,
s(:match_rest, nil),
s(:int, "1"),
s(:match_rest, nil))), nil,
s(:true)), nil)
3 changes: 3 additions & 0 deletions test/whitequark/test_find_pattern_2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typed: true

case foo; in Array[*, 1, *] then true; end
8 changes: 8 additions & 0 deletions test/whitequark/test_find_pattern_3.parse-tree-whitequark.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
s(:case_match,
s(:lvar, :foo),
s(:in_pattern,
s(:find_pattern,
s(:match_rest, nil),
s(:int, "42"),
s(:match_rest, nil)), nil,
s(:true)), nil)
3 changes: 3 additions & 0 deletions test/whitequark/test_find_pattern_3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typed: true

case foo; in *, 42, * then true; end
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# typed: true

1 in a, b # error: unexpected token ","
1 => a, b # error: unexpected token ","
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# typed: true

1 in a: # error: unexpected token tLABEL
1 => a: # error: unexpected token tLABEL
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
s(:begin,
s(:match_pattern,
s(:int, "1"),
s(:array_pattern,
s(:match_var, :a))),
s(:lvar, :a))
3 changes: 3 additions & 0 deletions test/whitequark/test_pattern_matching_single_line_0.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typed: true

1 => [a]; a
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
s(:begin,
s(:match_pattern_p,
s(:int, "1"),
s(:array_pattern,
s(:match_var, :a))),
s(:lvar, :a))
3 changes: 3 additions & 0 deletions test/whitequark/test_pattern_matching_single_line_1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# typed: true

1 in [a]; a

0 comments on commit 9b353db

Please sign in to comment.