Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ruby 3.0] Add support for find pattern (#4364)
* Import whitequark find pattern tests Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com> * [Ruby 3.0] Add support for find pattern Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
- Loading branch information
Showing
19 changed files
with
137 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/whitequark/test_find_pattern_0.parse-tree-whitequark.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
test/whitequark/test_find_pattern_1.parse-tree-whitequark.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
test/whitequark/test_find_pattern_2.parse-tree-whitequark.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
8
test/whitequark/test_find_pattern_3.parse-tree-whitequark.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# typed: true | ||
|
||
case foo; in *, 42, * then true; end |
2 changes: 1 addition & 1 deletion
2
test/whitequark/test_pattern_matching_required_parentheses_for_in_match_0.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "," |
2 changes: 1 addition & 1 deletion
2
test/whitequark/test_pattern_matching_required_parentheses_for_in_match_1.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
6 changes: 6 additions & 0 deletions
6
test/whitequark/test_pattern_matching_single_line_0.parse-tree-whitequark.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# typed: true | ||
|
||
1 => [a]; a |
6 changes: 6 additions & 0 deletions
6
test/whitequark/test_pattern_matching_single_line_1.parse-tree-whitequark.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# typed: true | ||
|
||
1 in [a]; a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters