Skip to content

Commit 7362b11

Browse files
committed
Avoid monkey patching Sexp#== in RubyParser tests
1 parent 9f55551 commit 7362b11

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

test/prism/ruby/ruby_parser_test.rb

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,22 @@
1313
return
1414
end
1515

16-
# We want to also compare lines and files to make sure we're setting them
17-
# correctly.
18-
Sexp.prepend(
19-
Module.new do
20-
def ==(other)
21-
super && line == other.line && file == other.file # && line_max == other.line_max
22-
end
23-
end
24-
)
25-
2616
module Prism
2717
class RubyParserTest < TestCase
2818
todos = [
2919
"encoding_euc_jp.txt",
30-
"newline_terminated.txt",
3120
"regex_char_width.txt",
32-
"seattlerb/bug169.txt",
3321
"seattlerb/masgn_colon3.txt",
3422
"seattlerb/messy_op_asgn_lineno.txt",
3523
"seattlerb/op_asgn_primary_colon_const_command_call.txt",
3624
"seattlerb/regexp_esc_C_slash.txt",
3725
"seattlerb/str_lit_concat_bad_encodings.txt",
3826
"strings.txt",
3927
"unescaping.txt",
40-
"unparser/corpus/literal/kwbegin.txt",
41-
"unparser/corpus/literal/send.txt",
4228
"whitequark/masgn_const.txt",
4329
"whitequark/pattern_matching_constants.txt",
44-
"whitequark/pattern_matching_implicit_array_match.txt",
4530
"whitequark/pattern_matching_single_match.txt",
4631
"whitequark/ruby_bug_12402.txt",
47-
"whitequark/ruby_bug_14690.txt",
48-
"whitequark/space_args_block.txt"
4932
]
5033

5134
# https://github.com/seattlerb/ruby_parser/issues/344
@@ -105,10 +88,16 @@ def assert_ruby_parser(fixture, allowed_failure)
10588
source = fixture.read
10689
expected = ignore_warnings { ::RubyParser.new.parse(source, fixture.path) }
10790
actual = Prism::Translation::RubyParser.new.parse(source, fixture.path)
91+
on_failure = -> { message(expected, actual) }
10892

10993
if !allowed_failure
110-
assert_equal(expected, actual, -> { message(expected, actual) })
111-
elsif expected == actual
94+
assert_equal(expected, actual, on_failure)
95+
96+
unless actual.nil?
97+
assert_equal(expected.line, actual.line, on_failure)
98+
assert_equal(expected.file, actual.file, on_failure)
99+
end
100+
elsif expected == actual && expected.line && actual.line && expected.file == actual.file
112101
puts "#{name} now passes"
113102
end
114103
end

0 commit comments

Comments
 (0)