2
2
3
3
require_relative "test_helper"
4
4
5
- File . delete ( "passing.txt" ) if File . exist? ( "passing.txt" )
6
- File . delete ( "failing.txt" ) if File . exist? ( "failing.txt" )
7
-
8
5
module Prism
9
6
class RipperTest < TestCase
10
7
base = File . join ( __dir__ , "fixtures" )
@@ -29,43 +26,36 @@ class RipperTest < TestCase
29
26
"whitequark/lvar_injecting_match.txt"
30
27
]
31
28
32
- heredocs = %w[
33
- dos_endings.txt
34
- heredocs_with_ignored_newlines.txt
35
- seattlerb/heredoc__backslash_dos_format.txt
36
- seattlerb/heredoc_backslash_nl.txt
37
- seattlerb/heredoc_nested.txt
38
- seattlerb/heredoc_squiggly.txt
39
- seattlerb/heredoc_squiggly_blank_line_plus_interpolation.txt
40
- seattlerb/heredoc_squiggly_blank_lines.txt
41
- seattlerb/heredoc_squiggly_interp.txt
42
- seattlerb/heredoc_squiggly_no_indent.txt
43
- seattlerb/heredoc_squiggly_tabs.txt
44
- seattlerb/heredoc_squiggly_tabs_extra.txt
45
- seattlerb/heredoc_squiggly_visually_blank_lines.txt
46
- spanning_heredoc.txt
47
- tilde_heredocs.txt
48
- unparser/corpus/semantic/dstr.txt
49
- whitequark/dedenting_heredoc.txt
50
- whitequark/dedenting_interpolating_heredoc_fake_line_continuation.txt
51
- whitequark/dedenting_non_interpolating_heredoc_line_continuation.txt
52
- whitequark/parser_bug_640.txt
53
- whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt
54
- whitequark/parser_slash_slash_n_escaping_in_literals.txt
55
- whitequark/slash_newline_in_heredocs.txt
56
- ]
57
-
58
- skips = incorrect | heredocs | %w[
59
- seattlerb/block_call_dot_op2_brace_block.txt
60
- seattlerb/block_command_operation_colon.txt
61
- seattlerb/block_command_operation_dot.txt
62
- whitequark/send_block_chain_cmd.txt
29
+ omitted = [
30
+ "dos_endings.txt" ,
31
+ "heredocs_with_ignored_newlines.txt" ,
32
+ "seattlerb/heredoc__backslash_dos_format.txt" ,
33
+ "seattlerb/heredoc_backslash_nl.txt" ,
34
+ "seattlerb/heredoc_nested.txt" ,
35
+ "seattlerb/heredoc_squiggly_blank_line_plus_interpolation.txt" ,
36
+ "seattlerb/heredoc_squiggly_no_indent.txt" ,
37
+ "spanning_heredoc.txt" ,
38
+ "tilde_heredocs.txt" ,
39
+ "unparser/corpus/semantic/dstr.txt" ,
40
+ "whitequark/dedenting_heredoc.txt" ,
41
+ "whitequark/parser_bug_640.txt" ,
42
+ "whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt" ,
43
+ "whitequark/parser_slash_slash_n_escaping_in_literals.txt" ,
44
+ "whitequark/slash_newline_in_heredocs.txt" ,
45
+
46
+ "seattlerb/block_call_dot_op2_brace_block.txt" ,
47
+ "seattlerb/block_command_operation_colon.txt" ,
48
+ "seattlerb/block_command_operation_dot.txt" ,
49
+ "whitequark/send_block_chain_cmd.txt"
63
50
]
64
51
65
52
relatives . each do |relative |
53
+ # Skip the tests that Ripper is reporting the wrong results for.
54
+ next if incorrect . include? ( relative )
66
55
filepath = File . join ( __dir__ , "fixtures" , relative )
67
56
68
57
define_method "test_ripper_#{ relative } " do
58
+ omit ( "Not yet implemented" ) if omitted . include? ( relative )
69
59
source = File . read ( filepath , binmode : true , external_encoding : Encoding ::UTF_8 )
70
60
71
61
case relative
@@ -78,23 +68,14 @@ class RipperTest < TestCase
78
68
source = "def __invalid_yield__\n #{ source } \n end"
79
69
end
80
70
81
- assert_ripper ( source , filepath , skips . include? ( relative ) )
71
+ assert_ripper ( source )
82
72
end
83
73
end
84
74
85
75
private
86
76
87
- def assert_ripper ( source , filepath , allowed_failure )
88
- expected = Ripper . sexp_raw ( source )
89
-
90
- begin
91
- assert_equal expected , Prism ::Translation ::Ripper . sexp_raw ( source )
92
- rescue Exception , NoMethodError
93
- File . open ( "failing.txt" , "a" ) { |f | f . puts filepath }
94
- raise unless allowed_failure
95
- else
96
- File . open ( "passing.txt" , "a" ) { |f | f . puts filepath } if allowed_failure
97
- end
77
+ def assert_ripper ( source )
78
+ assert_equal Ripper . sexp_raw ( source ) , Prism ::Translation ::Ripper . sexp_raw ( source )
98
79
end
99
80
end
100
81
end
0 commit comments