-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3367 from Earlopain/parser-translator-3.3-tests
Import code samples for Ruby 3.3 from the parser gem
- Loading branch information
Showing
69 changed files
with
6,580 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Copyright (c) 2013-2016 whitequark <[email protected]> | ||
Copyright (c) 2013-2024 parser project contributors | ||
Copyright (c) 2013-2016 Catherine <[email protected]> | ||
|
||
Parts of the source are derived from ruby_parser: | ||
Copyright (c) Ryan Davis, seattle.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
def f &b; end | ||
|
||
def f *r, &b; end | ||
|
||
def f *r, p, &b; end | ||
|
||
def f ; end | ||
|
||
def f a, &b; end | ||
|
||
def f a, *r, &b; end | ||
|
||
def f a, *r, p, &b; end | ||
|
||
def f a, o=1, &b; end | ||
|
||
def f a, o=1, *r, &b; end | ||
|
||
def f a, o=1, *r, p, &b; end | ||
|
||
def f a, o=1, p, &b; end | ||
|
||
def f o=1, &b; end | ||
|
||
def f o=1, *r, &b; end | ||
|
||
def f o=1, *r, p, &b; end | ||
|
||
def f o=1, p, &b; end |
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,57 @@ | ||
f{ } | ||
|
||
f{ | | } | ||
|
||
f{ |&b| } | ||
|
||
f{ |*, &b| } | ||
|
||
f{ |*r, p, &b| } | ||
|
||
f{ |*s, &b| } | ||
|
||
f{ |*s| } | ||
|
||
f{ |*| } | ||
|
||
f{ |; | ||
a | ||
| } | ||
|
||
f{ |;a| } | ||
|
||
f{ |a, &b| } | ||
|
||
f{ |a, *, &b| } | ||
|
||
f{ |a, *r, p, &b| } | ||
|
||
f{ |a, *s, &b| } | ||
|
||
f{ |a, *s| } | ||
|
||
f{ |a, *| } | ||
|
||
f{ |a, c| } | ||
|
||
f{ |a, o=1, &b| } | ||
|
||
f{ |a, o=1, *r, p, &b| } | ||
|
||
f{ |a, o=1, o1=2, *r, &b| } | ||
|
||
f{ |a, o=1, p, &b| } | ||
|
||
f{ |a,| } | ||
|
||
f{ |a| } | ||
|
||
f{ |o=1, &b| } | ||
|
||
f{ |o=1, *r, &b| } | ||
|
||
f{ |o=1, *r, p, &b| } | ||
|
||
f{ |o=1, p, &b| } | ||
|
||
f{ || } |
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 @@ | ||
f{ |foo:| } |
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,5 @@ | ||
f{ |**baz, &b| } | ||
|
||
f{ |foo: 1, &b| } | ||
|
||
f{ |foo: 1, bar: 2, **baz, &b| } |
1 change: 1 addition & 0 deletions
1
test/prism/fixtures/whitequark/emit_arg_inside_procarg0_legacy.txt
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 @@ | ||
f{ |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,7 @@ | ||
case foo; in *, 42, * then true; end | ||
|
||
case foo; in Array[*, 1, *] then true; end | ||
|
||
case foo; in String(*, 1, *) then true; end | ||
|
||
case foo; in [*x, 1 => a, *y] then true; end |
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,7 @@ | ||
def f (foo: 1, &b); end | ||
|
||
def f (foo: 1, bar: 2, **baz, &b); end | ||
|
||
def f **baz, &b; end | ||
|
||
def f *, **; end |
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,5 @@ | ||
def f foo: | ||
; end | ||
|
||
def f foo: -1 | ||
; end |
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 +1,3 @@ | ||
/(?<a>a)/ =~ 'a'; /#{}(?<b>b)/ =~ 'b'; a; b | ||
|
||
/(?<match>bar)/ =~ 'bar'; match |
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,19 @@ | ||
def f (((a))); end | ||
|
||
def f ((*)); end | ||
|
||
def f ((*, p)); end | ||
|
||
def f ((*r)); end | ||
|
||
def f ((*r, p)); end | ||
|
||
def f ((a, *)); end | ||
|
||
def f ((a, *, p)); end | ||
|
||
def f ((a, *r)); end | ||
|
||
def f ((a, *r, p)); end | ||
|
||
def f ((a, a1)); end |
1 change: 1 addition & 0 deletions
1
test/prism/fixtures/whitequark/multiple_args_with_trailing_comma.txt
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 @@ | ||
f{ |a, b,| } |
11 changes: 11 additions & 0 deletions
11
test/prism/fixtures/whitequark/pattern_matching_const_pattern.txt
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,11 @@ | ||
case foo; in A() then true; end | ||
|
||
case foo; in A(1, 2) then true; end | ||
|
||
case foo; in A(x:) then true; end | ||
|
||
case foo; in A[1, 2] then true; end | ||
|
||
case foo; in A[] then true; end | ||
|
||
case foo; in A[x:] then true; end |
5 changes: 5 additions & 0 deletions
5
test/prism/fixtures/whitequark/pattern_matching_constants.txt
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,5 @@ | ||
case foo; in ::A then true; end | ||
|
||
case foo; in A then true; end | ||
|
||
case foo; in A::B then true; end |
19 changes: 19 additions & 0 deletions
19
test/prism/fixtures/whitequark/pattern_matching_explicit_array_match.txt
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,19 @@ | ||
case foo; in [*, x] then true; end | ||
|
||
case foo; in [*x, y] then true; end | ||
|
||
case foo; in [x, *, y] then true; end | ||
|
||
case foo; in [x, *y, z] then true; end | ||
|
||
case foo; in [x, y, *] then true; end | ||
|
||
case foo; in [x, y, *z] then true; end | ||
|
||
case foo; in [x, y,] then true; end | ||
|
||
case foo; in [x, y] then true; end | ||
|
||
case foo; in [x,] then nil; end | ||
|
||
case foo; in [x] then nil; end |
1 change: 1 addition & 0 deletions
1
test/prism/fixtures/whitequark/pattern_matching_expr_in_paren.txt
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 @@ | ||
case foo; in (1) then true; end |
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,48 @@ | ||
case foo; | ||
in a: {b:}, c: | ||
p c | ||
; end | ||
|
||
case foo; | ||
in {Foo: 42 | ||
} | ||
false | ||
; end | ||
|
||
case foo; | ||
in {a: | ||
2} | ||
false | ||
; end | ||
|
||
case foo; | ||
in {a: | ||
} | ||
true | ||
; end | ||
|
||
case foo; | ||
in {a: 1 | ||
} | ||
false | ||
; end | ||
|
||
case foo; in ** then true; end | ||
|
||
case foo; in **a then true; end | ||
|
||
case foo; in a: 1 then true; end | ||
|
||
case foo; in a: 1, _a:, ** then true; end | ||
|
||
case foo; in a: 1, b: 2 then true; end | ||
|
||
case foo; in a: then true; end | ||
|
||
case foo; in a:, b: then true; end | ||
|
||
case foo; in { a: 1 } then true; end | ||
|
||
case foo; in { a: 1, } then true; end | ||
|
||
case foo; in {} then true; end |
3 changes: 3 additions & 0 deletions
3
test/prism/fixtures/whitequark/pattern_matching_if_unless_modifiers.txt
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 @@ | ||
case foo; in x if true; nil; end | ||
|
||
case foo; in x unless true; nil; end |
15 changes: 15 additions & 0 deletions
15
test/prism/fixtures/whitequark/pattern_matching_implicit_array_match.txt
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,15 @@ | ||
case foo; in * then nil; end | ||
|
||
case foo; in *x then nil; end | ||
|
||
case foo; in *x, y, z then nil; end | ||
|
||
case foo; in 1, "a", [], {} then nil; end | ||
|
||
case foo; in x, *y, z then nil; end | ||
|
||
case foo; in x, then nil; end | ||
|
||
case foo; in x, y then nil; end | ||
|
||
case foo; in x, y, then nil; end |
1 change: 1 addition & 0 deletions
1
test/prism/fixtures/whitequark/pattern_matching_keyword_variable.txt
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 @@ | ||
case foo; in self then true; end |
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 @@ | ||
case foo; in ->{ 42 } then true; end |
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 @@ | ||
case foo; in 1 | 2 then true; end |
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 @@ | ||
case foo; in 1 => a then true; end |
1 change: 1 addition & 0 deletions
1
test/prism/fixtures/whitequark/pattern_matching_nil_pattern.txt
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 @@ | ||
case foo; in **nil then true; end |
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 @@ | ||
case foo; in 1; end |
11 changes: 11 additions & 0 deletions
11
test/prism/fixtures/whitequark/pattern_matching_ranges.txt
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,11 @@ | ||
case foo; in ...2 then true; end | ||
|
||
case foo; in ..2 then true; end | ||
|
||
case foo; in 1.. then true; end | ||
|
||
case foo; in 1... then true; end | ||
|
||
case foo; in 1...2 then true; end | ||
|
||
case foo; in 1..2 then true; end |
1 change: 1 addition & 0 deletions
1
test/prism/fixtures/whitequark/pattern_matching_single_match.txt
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 @@ | ||
case foo; in x then x; end |
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,14 @@ | ||
case foo; in ^$TestPatternMatching; end | ||
|
||
case foo; in ^(0+0) then nil; end | ||
|
||
case foo; in ^(1 | ||
); end | ||
|
||
case foo; in ^(42) then nil; end | ||
|
||
case foo; in ^@@TestPatternMatching; end | ||
|
||
case foo; in ^@a; end | ||
|
||
case foo; in { foo: ^(42) } then nil; end |
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 @@ | ||
f{ |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 @@ | ||
Foo::Bar { |a| 42 } |
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,7 @@ | ||
a.b (1;2),(3),(4) | ||
|
||
a.b (;),(),() | ||
|
||
p (1;2),(3),(4) | ||
|
||
p (;),(),() |
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,9 @@ | ||
<<' FOO' | ||
[Bug #19539] | ||
FOO | ||
|
||
|
||
<<-' FOO' | ||
[Bug #19539] | ||
FOO | ||
|
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
Oops, something went wrong.