|
13 | 13 | return |
14 | 14 | end |
15 | 15 |
|
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 | | - |
26 | 16 | module Prism |
27 | 17 | class RubyParserTest < TestCase |
28 | 18 | todos = [ |
29 | 19 | "encoding_euc_jp.txt", |
30 | | - "newline_terminated.txt", |
31 | 20 | "regex_char_width.txt", |
32 | | - "seattlerb/bug169.txt", |
33 | 21 | "seattlerb/masgn_colon3.txt", |
34 | 22 | "seattlerb/messy_op_asgn_lineno.txt", |
35 | 23 | "seattlerb/op_asgn_primary_colon_const_command_call.txt", |
36 | 24 | "seattlerb/regexp_esc_C_slash.txt", |
37 | 25 | "seattlerb/str_lit_concat_bad_encodings.txt", |
38 | 26 | "strings.txt", |
39 | 27 | "unescaping.txt", |
40 | | - "unparser/corpus/literal/kwbegin.txt", |
41 | | - "unparser/corpus/literal/send.txt", |
42 | 28 | "whitequark/masgn_const.txt", |
43 | 29 | "whitequark/pattern_matching_constants.txt", |
44 | | - "whitequark/pattern_matching_implicit_array_match.txt", |
45 | 30 | "whitequark/pattern_matching_single_match.txt", |
46 | 31 | "whitequark/ruby_bug_12402.txt", |
47 | | - "whitequark/ruby_bug_14690.txt", |
48 | | - "whitequark/space_args_block.txt" |
49 | 32 | ] |
50 | 33 |
|
51 | 34 | # https://github.com/seattlerb/ruby_parser/issues/344 |
@@ -105,10 +88,16 @@ def assert_ruby_parser(fixture, allowed_failure) |
105 | 88 | source = fixture.read |
106 | 89 | expected = ignore_warnings { ::RubyParser.new.parse(source, fixture.path) } |
107 | 90 | actual = Prism::Translation::RubyParser.new.parse(source, fixture.path) |
| 91 | + on_failure = -> { message(expected, actual) } |
108 | 92 |
|
109 | 93 | 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 |
112 | 101 | puts "#{name} now passes" |
113 | 102 | end |
114 | 103 | end |
|
0 commit comments