Skip to content

Commit 1dc3675

Browse files
authored
Merge pull request #3531 from Earlopain/parser-translator-tests-explicit-skip
Be explicit in tests which files `parser` can't parse
2 parents f2443cf + bdcc8b3 commit 1dc3675

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ GEM
1515
mini_portile2 (~> 2.8.2)
1616
racc (~> 1.4)
1717
onigmo (0.1.0)
18-
parser (3.3.7.2)
18+
parser (3.3.7.4)
1919
ast (~> 2.4.1)
2020
racc
2121
power_assert (2.0.5)

test/prism/ruby/parser_test.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def ==(other)
5656

5757
module Prism
5858
class ParserTest < TestCase
59+
# These files contain code with valid syntax that can't be parsed.
60+
skip_syntax_error = [
61+
# alias/undef with %s(abc) symbol literal
62+
"alias.txt",
63+
"seattlerb/bug_215.txt",
64+
65+
# 1.. && 2
66+
"ranges.txt",
67+
]
68+
5969
# These files contain code that is being parsed incorrectly by the parser
6070
# gem, and therefore we don't want to compare against our translation.
6171
skip_incorrect = [
@@ -133,7 +143,7 @@ class ParserTest < TestCase
133143
"whitequark/space_args_block.txt"
134144
]
135145

136-
Fixture.each do |fixture|
146+
Fixture.each(except: skip_syntax_error) do |fixture|
137147
define_method(fixture.test_name) do
138148
assert_equal_parses(
139149
fixture,
@@ -190,11 +200,7 @@ def assert_equal_parses(fixture, compare_asts: true, compare_tokens: true, compa
190200
parser.diagnostics.all_errors_are_fatal = true
191201

192202
expected_ast, expected_comments, expected_tokens =
193-
begin
194-
ignore_warnings { parser.tokenize(buffer) }
195-
rescue ArgumentError, Parser::SyntaxError
196-
return
197-
end
203+
ignore_warnings { parser.tokenize(buffer) }
198204

199205
actual_ast, actual_comments, actual_tokens =
200206
ignore_warnings { Prism::Translation::Parser33.new.tokenize(buffer) }

0 commit comments

Comments
 (0)