Skip to content

Commit d5365f0

Browse files
committed
Update to latest seattlerb
1 parent f11e07c commit d5365f0

Some content is hidden

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

60 files changed

+738
-359
lines changed

rakelib/seattlerb.rake

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
# frozen_string_literal: true
22

3-
# These files are not valid Ruby
4-
known_failures = %w(
5-
test/fixtures/seattlerb/begin_else_return_value.txt
6-
test/fixtures/seattlerb/block_yield.txt
7-
test/fixtures/seattlerb/bug_begin_else.txt
8-
test/fixtures/seattlerb/bug170.txt
9-
test/fixtures/seattlerb/call_block_arg_unnamed.txt
10-
test/fixtures/seattlerb/iter_array_curly.txt
11-
test/fixtures/seattlerb/magic_encoding_comment__bad.txt
12-
)
13-
143
namespace :seattlerb do
154
desc "Ensure there's a local copy of seattlerb/ruby_parser"
165
file "tmp/seattlerb" do
@@ -24,6 +13,35 @@ namespace :seattlerb do
2413

2514
desc "Import the seattlerb tests"
2615
task import: ["tmp/seattlerb", "test/fixtures/seattlerb"] do
16+
require "base64"
17+
18+
# These files are not valid Ruby
19+
known_failures = %w[
20+
test/fixtures/seattlerb/args_dstar__anon_solo.txt
21+
test/fixtures/seattlerb/args_dstar__anon_trailing.txt
22+
test/fixtures/seattlerb/args_star__anon_solo.txt
23+
test/fixtures/seattlerb/args_star__anon_trailing.txt
24+
test/fixtures/seattlerb/begin_else_return_value.txt
25+
test/fixtures/seattlerb/block_yield.txt
26+
test/fixtures/seattlerb/bug_begin_else.txt
27+
test/fixtures/seattlerb/bug170.txt
28+
test/fixtures/seattlerb/call_block_arg_unnamed.txt
29+
test/fixtures/seattlerb/iter_array_curly.txt
30+
test/fixtures/seattlerb/magic_encoding_comment__bad.txt
31+
]
32+
33+
# Cleaning up some file names
34+
renames = [
35+
"aGVyZWRvY193dGZfSV9oYXRlX3lvdQ==\n",
36+
"aV9mdWNraW5nX2hhdGVf\n",
37+
"aV9oYXZlX25vX2ZyZWFraW5fY2x1ZQ==\n",
38+
"a2lsbF9tZQ==\n",
39+
"bW90aGVyZnVja2lu\n",
40+
"d3RmX2lfaGF0ZV95b3U=\n",
41+
"d3Rm\n",
42+
"em9tZ19zb21ldGltZXNfaV9oYXRlX3RoaXNfcHJvamVjdA==\n"
43+
].map { Base64.decode64(_1) }
44+
2745
# The license is in the README
2846
cp "tmp/seattlerb/README.rdoc", "test/fixtures/seattlerb/README.rdoc"
2947

@@ -36,7 +54,7 @@ namespace :seattlerb do
3654

3755
def assert_parse(source, _)
3856
entry = caller.find { _1.include?("test_ruby_parser.rb") }
39-
name = entry[/\d+:in `(?:block in )?(?:assert_|test_)?(.+)'/, 1]
57+
name = entry[/\d+:in `(?:block (?:\(\d+ levels\) )?in )?(?:assert_|test_|<module:)?(.+?)\>?'/, 1]
4058

4159
COLLECTED[name] << source
4260
super
@@ -46,7 +64,17 @@ namespace :seattlerb do
4664
RubyParserTestCase.prepend(Hook)
4765
Minitest.after_run do
4866
Hook::COLLECTED.each do |(name, codes)|
49-
filepath = "test/fixtures/seattlerb/#{name.delete!('?')}.txt"
67+
name = name.delete("?")
68+
69+
# Clean up the names a bit
70+
renames.each_with_index do |rename, index|
71+
if name.start_with?(rename)
72+
name = "difficult#{index}_#{name.delete_prefix(rename)}"
73+
break
74+
end
75+
end
76+
77+
filepath = "test/fixtures/seattlerb/#{name}.txt"
5078
File.write(filepath, "#{codes.uniq.sort.join("\n\n")}\n")
5179
end
5280

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
%I[
2+
3+
4+
]
5+
6+
%I[
7+
line2
8+
line3
9+
]
10+
11+
%W[
12+
13+
14+
]
15+
16+
%W[
17+
line2
18+
line3
19+
]
20+
21+
%i[
22+
23+
24+
]
25+
26+
%i[
27+
line2
28+
line3
29+
]
30+
31+
%r[
32+
33+
34+
]
35+
36+
%w[
37+
38+
39+
]
40+
41+
%w[
42+
line2
43+
line3
44+
]
45+
46+
[
47+
:line2,
48+
:line3
49+
]
50+
51+
class X # line 1
52+
def self.y(a, # line 2
53+
b) # line 3
54+
a + b # line 4
55+
end # line 5
56+
end # line 6
57+
58+
59+
class X # line 1
60+
class Y # line 2
61+
Z = 42 # line 3
62+
end # line 4
63+
end # line 5
64+
65+
66+
class X # line 1
67+
def y(a, # line 2
68+
b) # line 3
69+
a + b # line 4
70+
end # line 5
71+
end # line 6
72+
73+
74+
module X
75+
X = [
76+
:line3,
77+
:line4,
78+
]
79+
end
80+
81+
82+
module X # line 1
83+
module Y # line 2
84+
Z = 42 # line 3
85+
end # line 4
86+
end # line 5
87+
88+
89+
x(
90+
:line2,
91+
:line3
92+
)

test/fixtures/seattlerb/case_in.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
case :a
2-
in "b":
2+
in "b":
33
end
44

55
case :a
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def f ...
2+
m(...)
3+
end

test/fixtures/seattlerb/i_fucking_hate_line_numbers2.txt renamed to test/fixtures/seattlerb/difficult1_line_numbers2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if true then
2-
p('a')
2+
p("a")
33
b = 1
44
p b
55
c =1

0 commit comments

Comments
 (0)