@@ -42,14 +42,9 @@ def ==(other)
42
42
43
43
module Prism
44
44
class ParserTest < TestCase
45
- # These files are erroring because of the parser gem being wrong.
46
- skip_incorrect = [
47
- "embdoc_no_newline_at_end.txt"
48
- ]
49
-
50
45
# These files are either failing to parse or failing to translate, so we'll
51
46
# skip them for now.
52
- skip_all = skip_incorrect | [
47
+ skip_all = [
53
48
"dash_heredocs.txt" ,
54
49
"dos_endings.txt" ,
55
50
"heredocs_with_ignored_newlines.txt" ,
@@ -58,15 +53,12 @@ class ParserTest < TestCase
58
53
"spanning_heredoc.txt" ,
59
54
"spanning_heredoc_newlines.txt" ,
60
55
"unescaping.txt" ,
61
- "seattlerb/backticks_interpolation_line.txt" ,
62
56
"seattlerb/block_decomp_anon_splat_arg.txt" ,
63
57
"seattlerb/block_decomp_arg_splat_arg.txt" ,
64
58
"seattlerb/block_decomp_arg_splat.txt" ,
65
59
"seattlerb/block_decomp_splat.txt" ,
66
60
"seattlerb/block_paren_splat.txt" ,
67
61
"seattlerb/bug190.txt" ,
68
- "seattlerb/case_in_hash_pat_rest_solo.txt" ,
69
- "seattlerb/case_in_hash_pat_rest.txt" ,
70
62
"seattlerb/case_in.txt" ,
71
63
"seattlerb/heredoc_nested.txt" ,
72
64
"seattlerb/heredoc_squiggly_blank_line_plus_interpolation.txt" ,
@@ -78,8 +70,6 @@ class ParserTest < TestCase
78
70
"seattlerb/masgn_double_paren.txt" ,
79
71
"seattlerb/parse_line_heredoc_hardnewline.txt" ,
80
72
"seattlerb/parse_pattern_044.txt" ,
81
- "seattlerb/parse_pattern_058_2.txt" ,
82
- "seattlerb/parse_pattern_058.txt" ,
83
73
"seattlerb/pct_nl.txt" ,
84
74
"seattlerb/pctW_lineno.txt" ,
85
75
"seattlerb/regexp_esc_C_slash.txt" ,
@@ -91,7 +81,6 @@ class ParserTest < TestCase
91
81
"unparser/corpus/literal/literal.txt" ,
92
82
"unparser/corpus/literal/pattern.txt" ,
93
83
"unparser/corpus/semantic/dstr.txt" ,
94
- "unparser/corpus/semantic/opasgn.txt" ,
95
84
"whitequark/dedenting_interpolating_heredoc_fake_line_continuation.txt" ,
96
85
"whitequark/masgn_nested.txt" ,
97
86
"whitequark/newline_in_hash_argument.txt" ,
@@ -111,12 +100,14 @@ class ParserTest < TestCase
111
100
# output expected by the parser gem, so we'll skip them for now.
112
101
skip_tokens = [
113
102
"comments.txt" ,
103
+ "embdoc_no_newline_at_end.txt" ,
114
104
"heredoc_with_comment.txt" ,
115
105
"indented_file_end.txt" ,
116
106
"methods.txt" ,
117
107
"strings.txt" ,
118
108
"tilde_heredocs.txt" ,
119
109
"xstring_with_backslash.txt" ,
110
+ "seattlerb/backticks_interpolation_line.txt" ,
120
111
"seattlerb/bug169.txt" ,
121
112
"seattlerb/class_comments.txt" ,
122
113
"seattlerb/difficult4__leading_dots2.txt" ,
@@ -164,6 +155,7 @@ class ParserTest < TestCase
164
155
"seattlerb/str_single_newline.txt" ,
165
156
"seattlerb/symbol_empty.txt" ,
166
157
"seattlerb/symbols_empty_space.txt" ,
158
+ "unparser/corpus/semantic/opasgn.txt" ,
167
159
"whitequark/args.txt" ,
168
160
"whitequark/beginless_erange_after_newline.txt" ,
169
161
"whitequark/beginless_irange_after_newline.txt" ,
@@ -183,15 +175,20 @@ class ParserTest < TestCase
183
175
"whitequark/space_args_block.txt"
184
176
]
185
177
186
- Fixture . each ( except : skip_all ) do |fixture |
178
+ Fixture . each do |fixture |
187
179
define_method ( fixture . test_name ) do
188
- assert_equal_parses ( fixture , compare_tokens : !skip_tokens . include? ( fixture . path ) )
180
+ assert_equal_parses (
181
+ fixture ,
182
+ compare_asts : !skip_all . include? ( fixture . path ) ,
183
+ compare_tokens : !skip_tokens . include? ( fixture . path ) ,
184
+ compare_comments : fixture . path != "embdoc_no_newline_at_end.txt"
185
+ )
189
186
end
190
187
end
191
188
192
189
private
193
190
194
- def assert_equal_parses ( fixture , compare_tokens : true )
191
+ def assert_equal_parses ( fixture , compare_asts : true , compare_tokens : true , compare_comments : true )
195
192
buffer = Parser ::Source ::Buffer . new ( fixture . path , 1 )
196
193
buffer . source = fixture . read
197
194
@@ -209,9 +206,17 @@ def assert_equal_parses(fixture, compare_tokens: true)
209
206
actual_ast , actual_comments , actual_tokens =
210
207
ignore_warnings { Prism ::Translation ::Parser33 . new . tokenize ( buffer ) }
211
208
212
- assert_equal expected_ast , actual_ast , -> { assert_equal_asts_message ( expected_ast , actual_ast ) }
213
- assert_equal_tokens ( expected_tokens , actual_tokens ) if compare_tokens
214
- assert_equal_comments ( expected_comments , actual_comments )
209
+ if expected_ast == actual_ast
210
+ if !compare_asts
211
+ puts "#{ fixture . path } is now passing"
212
+ end
213
+
214
+ assert_equal expected_ast , actual_ast , -> { assert_equal_asts_message ( expected_ast , actual_ast ) }
215
+ assert_equal_tokens ( expected_tokens , actual_tokens ) if compare_tokens
216
+ assert_equal_comments ( expected_comments , actual_comments ) if compare_comments
217
+ elsif compare_asts
218
+ flunk "expected: #{ expected_ast . inspect } \n actual: #{ actual_ast . inspect } "
219
+ end
215
220
end
216
221
217
222
def assert_equal_asts_message ( expected_ast , actual_ast )
0 commit comments