|
6 | 6 |
|
7 | 7 | module Prism |
8 | 8 | class LexTest < TestCase |
9 | | - except = [ |
10 | | - # https://bugs.ruby-lang.org/issues/21756 |
11 | | - "spanning_heredoc.txt", |
12 | | - # Prism emits a single string in some cases when ripper splits them up |
13 | | - "whitequark/dedenting_heredoc.txt", |
14 | | - "heredocs_with_fake_newlines.txt", |
15 | | - # Prism emits BEG for `on_regexp_end` |
16 | | - "spanning_heredoc_newlines.txt", |
17 | | - ] |
18 | | - |
19 | | - if RUBY_VERSION < "3.3.0" |
20 | | - # This file has changed behavior in Ripper in Ruby 3.3, so we skip it if |
21 | | - # we're on an earlier version. |
22 | | - except << "seattlerb/pct_w_heredoc_interp_nested.txt" |
23 | | - |
24 | | - # Ruby < 3.3.0 cannot parse heredocs where there are leading whitespace |
25 | | - # characters in the heredoc start. |
26 | | - # Example: <<~' EOF' or <<-' EOF' |
27 | | - # https://bugs.ruby-lang.org/issues/19539 |
28 | | - except << "heredocs_leading_whitespace.txt" |
29 | | - except << "whitequark/ruby_bug_19539.txt" |
30 | | - |
31 | | - # https://bugs.ruby-lang.org/issues/19025 |
32 | | - except << "whitequark/numparam_ruby_bug_19025.txt" |
33 | | - # https://bugs.ruby-lang.org/issues/18878 |
34 | | - except << "whitequark/ruby_bug_18878.txt" |
35 | | - # https://bugs.ruby-lang.org/issues/19281 |
36 | | - except << "whitequark/ruby_bug_19281.txt" |
37 | | - end |
38 | | - |
39 | | - # https://bugs.ruby-lang.org/issues/21168#note-5 |
40 | | - except << "command_method_call_2.txt" |
41 | | - |
42 | | - Fixture.each_for_current_ruby(except: except) do |fixture| |
43 | | - define_method(fixture.test_name) { assert_lex(fixture) } |
44 | | - end |
45 | | - |
46 | 9 | def test_lex_file |
47 | 10 | assert_nothing_raised do |
48 | 11 | Prism.lex_file(__FILE__) |
@@ -83,16 +46,11 @@ def test_parse_lex_file |
83 | 46 | end |
84 | 47 | end |
85 | 48 |
|
86 | | - private |
87 | | - |
88 | | - def assert_lex(fixture) |
89 | | - source = fixture.read |
90 | | - |
91 | | - result = Prism.lex_compat(source, version: "current") |
92 | | - assert_equal [], result.errors |
93 | | - |
94 | | - Prism.lex_ripper(source).zip(result.value).each do |(ripper, prism)| |
95 | | - assert_equal ripper, prism |
| 49 | + if RUBY_VERSION >= "3.3" |
| 50 | + def test_lex_compare |
| 51 | + prism = Prism.lex_compat(File.read(__FILE__), version: "current").value |
| 52 | + ripper = Prism.lex_ripper(File.read(__FILE__)) |
| 53 | + assert_equal(ripper, prism) |
96 | 54 | end |
97 | 55 | end |
98 | 56 | end |
|
0 commit comments