Skip to content

Commit d543fda

Browse files
Earlopainmatzbot
authored andcommitted
[ruby/prism] Be explicit in tests which files parser can't parse
It also updates to latest `parser`, which allows numbered parameters in pattern matching pin, passing `patterns.txt` and `case.txt` ruby/prism@bdcc8b3dc5
1 parent 334c261 commit d543fda

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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)