Skip to content

Commit 2fdb106

Browse files
authored
Merge pull request #3367 from Earlopain/parser-translator-3.3-tests
Import code samples for Ruby 3.3 from the parser gem
2 parents 4519d9f + 9b5b785 commit 2fdb106

File tree

69 files changed

+6580
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+6580
-28
lines changed

rakelib/whitequark.rake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace :whitequark do
3838
# This object is going to collect all of the examples from the parser gem
3939
# into a hash that we can use to generate our own tests.
4040
COLLECTED = Hash.new { |hash, key| hash[key] = [] }
41-
ALL_VERSIONS = %w[3.1 3.2]
41+
ALL_VERSIONS = %w[3.1 3.2 3.3]
4242

4343
private
4444

@@ -60,10 +60,10 @@ namespace :whitequark do
6060
def assert_parses(_ast, code, _source_maps = "", versions = ALL_VERSIONS)
6161
# We're going to skip any examples that are for older Ruby versions
6262
# that we do not support.
63-
return if (versions & %w[3.1 3.2]).empty?
63+
return if (versions & ALL_VERSIONS).empty?
6464

65-
entry = caller.find { _1.include?("test_parser.rb") }
66-
_, name = *entry.match(/\d+:in `(?:block in )?(?:test_|assert_parses_)?(.+)'/)
65+
entry = caller_locations.find { _1.base_label.start_with?("test_") }
66+
name = entry.base_label.delete_prefix("test_")
6767

6868
COLLECTED[name] << code
6969
end
@@ -94,7 +94,8 @@ namespace :whitequark do
9494
test/prism/fixtures/whitequark/if_while_after_class__since_32.txt
9595
test/prism/fixtures/whitequark/next_block.txt
9696
test/prism/fixtures/whitequark/next.txt
97-
test/prism/fixtures/whitequark/pattern_match.txt
97+
test/prism/fixtures/whitequark/pattern_matching_pin_variable.txt
98+
test/prism/fixtures/whitequark/pattern_matching_hash_with_string_keys.txt
9899
test/prism/fixtures/whitequark/range_endless.txt
99100
test/prism/fixtures/whitequark/redo.txt
100101
test/prism/fixtures/whitequark/retry.txt

test/prism/fixtures/whitequark/LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Copyright (c) 2013-2016 whitequark <[email protected]>
1+
Copyright (c) 2013-2024 parser project contributors
2+
Copyright (c) 2013-2016 Catherine <[email protected]>
23

34
Parts of the source are derived from ruby_parser:
45
Copyright (c) Ryan Davis, seattle.rb
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
def f &b; end
2+
3+
def f *r, &b; end
4+
5+
def f *r, p, &b; end
6+
7+
def f ; end
8+
9+
def f a, &b; end
10+
11+
def f a, *r, &b; end
12+
13+
def f a, *r, p, &b; end
14+
15+
def f a, o=1, &b; end
16+
17+
def f a, o=1, *r, &b; end
18+
19+
def f a, o=1, *r, p, &b; end
20+
21+
def f a, o=1, p, &b; end
22+
23+
def f o=1, &b; end
24+
25+
def f o=1, *r, &b; end
26+
27+
def f o=1, *r, p, &b; end
28+
29+
def f o=1, p, &b; end
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
f{ }
2+
3+
f{ | | }
4+
5+
f{ |&b| }
6+
7+
f{ |*, &b| }
8+
9+
f{ |*r, p, &b| }
10+
11+
f{ |*s, &b| }
12+
13+
f{ |*s| }
14+
15+
f{ |*| }
16+
17+
f{ |;
18+
a
19+
| }
20+
21+
f{ |;a| }
22+
23+
f{ |a, &b| }
24+
25+
f{ |a, *, &b| }
26+
27+
f{ |a, *r, p, &b| }
28+
29+
f{ |a, *s, &b| }
30+
31+
f{ |a, *s| }
32+
33+
f{ |a, *| }
34+
35+
f{ |a, c| }
36+
37+
f{ |a, o=1, &b| }
38+
39+
f{ |a, o=1, *r, p, &b| }
40+
41+
f{ |a, o=1, o1=2, *r, &b| }
42+
43+
f{ |a, o=1, p, &b| }
44+
45+
f{ |a,| }
46+
47+
f{ |a| }
48+
49+
f{ |o=1, &b| }
50+
51+
f{ |o=1, *r, &b| }
52+
53+
f{ |o=1, *r, p, &b| }
54+
55+
f{ |o=1, p, &b| }
56+
57+
f{ || }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f{ |foo:| }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
f{ |**baz, &b| }
2+
3+
f{ |foo: 1, &b| }
4+
5+
f{ |foo: 1, bar: 2, **baz, &b| }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f{ |a| }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
case foo; in *, 42, * then true; end
2+
3+
case foo; in Array[*, 1, *] then true; end
4+
5+
case foo; in String(*, 1, *) then true; end
6+
7+
case foo; in [*x, 1 => a, *y] then true; end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def f (foo: 1, &b); end
2+
3+
def f (foo: 1, bar: 2, **baz, &b); end
4+
5+
def f **baz, &b; end
6+
7+
def f *, **; end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def f foo:
2+
; end
3+
4+
def f foo: -1
5+
; end

0 commit comments

Comments
 (0)