Skip to content

Commit c1f28f2

Browse files
koicbbatsov
authored andcommitted
Run tests with Prism 0.25+
The tests are being updated to use Prism 0.25+ from Prism 0.24. Prism 0.25 has fixed many issues, allowing for the execution of tests that were previously skipped due to `broken_on: :prism`. For future purposes, `broken_on: :prism` is intentionally left in the spec_helper.rb. Furthermore, Prism 0.25 appropriately addresses the following syntax as an error: ```console $ ruby -ve "break" ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22] -e:1: Invalid break break -e: compile error (SyntaxError) ``` However, the Parser gem incorrectly parses it: ```console $ ruby-parse --33 -e "break" (break) ``` This issue is expected to be reported to the Parser gem separately.
1 parent f0e475a commit c1f28f2

File tree

54 files changed

+742
-726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+742
-726
lines changed

Gemfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ gem 'asciidoctor'
88
gem 'bump', require: false
99
gem 'bundler', '>= 1.15.0', '< 3.0'
1010
gem 'memory_profiler', platform: :mri
11-
# FIXME: This is a workaround for incompatibilities between Prism 0.24.0 and 0.25.0.
12-
# To upgrade to Prism 0.25+, it is necessary to investigate the following build error
13-
# and provide feedback to Prism:
14-
# https://github.com/rubocop/rubocop/actions/runs/8578707777/job/23512878899
15-
gem 'prism', '0.24.0'
11+
gem 'prism', '>= 0.25.0'
1612
gem 'rake', '~> 13.0'
1713
gem 'rspec', '~> 3.7'
1814
gem 'rubocop-performance', '~> 1.21.0'

spec/rubocop/cop/alignment_corrector_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@
6969
it_behaves_like 'heredoc indenter', '<<DOC', 20
7070
end
7171

72-
# FIXME: https://github.com/ruby/prism/issues/2498
73-
context 'with heredoc in backticks (<<``)', broken_on: :prism do
72+
context 'with heredoc in backticks (<<``)' do
7473
it_behaves_like 'heredoc indenter', '<<`DOC`', 20
7574
end
7675
end

spec/rubocop/cop/internal_affairs/location_line_equality_comparison_spec.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# frozen_string_literal: true
22

3-
# FIXME: `undefined method `[]' for nil` occurs Prism 0.24.0. It has been resolved in
4-
# the development line. This will be resolved in Prism > 0.24.0 and higher releases.
5-
# rubocop:disable Layout/LineLength
6-
RSpec.describe RuboCop::Cop::InternalAffairs::LocationLineEqualityComparison, :config, broken_on: :prism do
7-
# rubocop:enable Layout/LineLength
3+
RSpec.describe RuboCop::Cop::InternalAffairs::LocationLineEqualityComparison, :config do
84
it 'registers and corrects an offense when comparing `#loc.line` with LHS and RHS' do
95
expect_offense(<<~RUBY)
106
node.loc.line == node.parent.loc.line

spec/rubocop/cop/layout/case_indentation_spec.rb

Lines changed: 94 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,23 @@
130130
RUBY
131131
end
132132

133-
it "accepts a `when` clause that's equally indented with `case`" do
134-
expect_no_offenses(<<~RUBY)
135-
y = case a
136-
when 0 then break
137-
when 0 then return
138-
else
139-
z = case b
140-
when 1 then return
141-
when 1 then break
142-
end
143-
end
144-
case c
145-
when 2 then encoding
146-
end
147-
RUBY
133+
context 'Ruby <= 3.2', :ruby32, unsupported_on: :prism do
134+
it "accepts a `when` clause that's equally indented with `case`" do
135+
expect_no_offenses(<<~RUBY)
136+
y = case a
137+
when 0 then break
138+
when 0 then return
139+
else
140+
z = case b
141+
when 1 then return
142+
when 1 then break
143+
end
144+
end
145+
case c
146+
when 2 then encoding
147+
end
148+
RUBY
149+
end
148150
end
149151

150152
it "doesn't get confused by strings with `case` in them" do
@@ -310,21 +312,23 @@
310312
RUBY
311313
end
312314

313-
it "accepts an `in` clause that's equally indented with `case`" do
314-
expect_no_offenses(<<~RUBY)
315-
y = case a
316-
in 0 then break
317-
in 0 then return
318-
else
319-
z = case b
320-
in 1 then return
321-
in 1 then break
322-
end
323-
end
324-
case c
325-
in 2 then encoding
326-
end
327-
RUBY
315+
context 'Ruby <= 3.2', :ruby32, unsupported_on: :prism do
316+
it "accepts an `in` clause that's equally indented with `case`" do
317+
expect_no_offenses(<<~RUBY)
318+
y = case a
319+
in 0 then break
320+
in 0 then return
321+
else
322+
z = case b
323+
in 1 then return
324+
in 1 then break
325+
end
326+
end
327+
case c
328+
in 2 then encoding
329+
end
330+
RUBY
331+
end
328332
end
329333

330334
it "doesn't get confused by strings with `case` in them" do
@@ -428,39 +432,41 @@
428432
RUBY
429433
end
430434

431-
it 'registers an offense and corrects a `when` clause that is equally indented with `case`' do
432-
expect_offense(<<~RUBY)
433-
y = case a
434-
when 0 then break
435-
^^^^ Indent `when` one step more than `case`.
436-
when 0 then return
437-
^^^^ Indent `when` one step more than `case`.
438-
z = case b
439-
when 1 then return
440-
^^^^ Indent `when` one step more than `case`.
441-
when 1 then break
442-
^^^^ Indent `when` one step more than `case`.
443-
end
444-
end
445-
case c
446-
when 2 then encoding
447-
^^^^ Indent `when` one step more than `case`.
448-
end
449-
RUBY
450-
451-
expect_correction(<<~RUBY)
452-
y = case a
435+
context 'Ruby <= 3.2', :ruby32, unsupported_on: :prism do
436+
it 'registers an offense and corrects a `when` clause that is equally indented with `case`' do
437+
expect_offense(<<~RUBY)
438+
y = case a
453439
when 0 then break
440+
^^^^ Indent `when` one step more than `case`.
454441
when 0 then return
455-
z = case b
442+
^^^^ Indent `when` one step more than `case`.
443+
z = case b
456444
when 1 then return
445+
^^^^ Indent `when` one step more than `case`.
457446
when 1 then break
458-
end
459-
end
460-
case c
447+
^^^^ Indent `when` one step more than `case`.
448+
end
449+
end
450+
case c
461451
when 2 then encoding
462-
end
463-
RUBY
452+
^^^^ Indent `when` one step more than `case`.
453+
end
454+
RUBY
455+
456+
expect_correction(<<~RUBY)
457+
y = case a
458+
when 0 then break
459+
when 0 then return
460+
z = case b
461+
when 1 then return
462+
when 1 then break
463+
end
464+
end
465+
case c
466+
when 2 then encoding
467+
end
468+
RUBY
469+
end
464470
end
465471

466472
context 'when indentation width is overridden for this cop only' do
@@ -538,39 +544,41 @@
538544
RUBY
539545
end
540546

541-
it 'registers an offense and corrects an `in` clause that is equally indented with `case`' do
542-
expect_offense(<<~RUBY)
543-
y = case a
544-
in 0 then break
545-
^^ Indent `in` one step more than `case`.
546-
in 0 then return
547-
^^ Indent `in` one step more than `case`.
548-
z = case b
549-
in 1 then return
550-
^^ Indent `in` one step more than `case`.
551-
in 1 then break
552-
^^ Indent `in` one step more than `case`.
553-
end
554-
end
555-
case c
556-
in 2 then encoding
557-
^^ Indent `in` one step more than `case`.
558-
end
559-
RUBY
560-
561-
expect_correction(<<~RUBY)
562-
y = case a
547+
context 'Ruby <= 3.2', :ruby32, unsupported_on: :prism do
548+
it 'registers an offense and corrects an `in` clause that is equally indented with `case`' do
549+
expect_offense(<<~RUBY)
550+
y = case a
563551
in 0 then break
552+
^^ Indent `in` one step more than `case`.
564553
in 0 then return
565-
z = case b
554+
^^ Indent `in` one step more than `case`.
555+
z = case b
566556
in 1 then return
557+
^^ Indent `in` one step more than `case`.
567558
in 1 then break
568-
end
569-
end
570-
case c
559+
^^ Indent `in` one step more than `case`.
560+
end
561+
end
562+
case c
571563
in 2 then encoding
572-
end
573-
RUBY
564+
^^ Indent `in` one step more than `case`.
565+
end
566+
RUBY
567+
568+
expect_correction(<<~RUBY)
569+
y = case a
570+
in 0 then break
571+
in 0 then return
572+
z = case b
573+
in 1 then return
574+
in 1 then break
575+
end
576+
end
577+
case c
578+
in 2 then encoding
579+
end
580+
RUBY
581+
end
574582
end
575583

576584
context 'when indentation width is overridden for this cop only' do

spec/rubocop/cop/layout/class_structure_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ def do_something
362362
RUBY
363363
end
364364

365-
# FIXME: https://github.com/ruby/prism/issues/2498
366-
it 'registers an offense and corrects when xstr heredoc constant is defined after public method', broken_on: :prism do
365+
it 'registers an offense and corrects when xstr heredoc constant is defined after public method' do
367366
expect_offense(<<~RUBY)
368367
class Foo
369368
def do_something

spec/rubocop/cop/layout/empty_line_after_guard_clause_spec.rb

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,24 @@ def foo
2525
RUBY
2626
end
2727

28-
it 'registers an offense and corrects `next` guard clause not followed by empty line' do
29-
expect_offense(<<~RUBY)
30-
def foo
31-
next unless need_next? # comment
32-
^^^^^^^^^^^^^^^^^^^^^^ Add empty line after guard clause.
33-
foobar
34-
end
35-
RUBY
28+
context 'Ruby <= 3.2', :ruby32, unsupported_on: :prism do # rubocop:disable RSpec/RepeatedExampleGroupDescription
29+
it 'registers an offense and corrects `next` guard clause not followed by empty line' do
30+
expect_offense(<<~RUBY)
31+
def foo
32+
next unless need_next? # comment
33+
^^^^^^^^^^^^^^^^^^^^^^ Add empty line after guard clause.
34+
foobar
35+
end
36+
RUBY
3637

37-
expect_correction(<<~RUBY)
38-
def foo
39-
next unless need_next? # comment
38+
expect_correction(<<~RUBY)
39+
def foo
40+
next unless need_next? # comment
4041
41-
foobar
42-
end
43-
RUBY
42+
foobar
43+
end
44+
RUBY
45+
end
4446
end
4547

4648
it 'registers an offense and corrects a guard clause is before `begin`' do
@@ -528,42 +530,44 @@ def foo
528530
RUBY
529531
end
530532

531-
it 'registers an offense and corrects a method starting with end_' do
532-
expect_offense(<<~RUBY)
533-
def foo
534-
next unless need_next?
535-
^^^^^^^^^^^^^^^^^^^^^^ Add empty line after guard clause.
536-
end_this!
537-
end
538-
RUBY
539-
540-
expect_correction(<<~RUBY)
541-
def foo
542-
next unless need_next?
533+
context 'Ruby <= 3.2', :ruby32, unsupported_on: :prism do # rubocop:disable RSpec/RepeatedExampleGroupDescription
534+
it 'registers an offense and corrects a method starting with end_' do
535+
expect_offense(<<~RUBY)
536+
def foo
537+
next unless need_next?
538+
^^^^^^^^^^^^^^^^^^^^^^ Add empty line after guard clause.
539+
end_this!
540+
end
541+
RUBY
543542

544-
end_this!
545-
end
546-
RUBY
547-
end
543+
expect_correction(<<~RUBY)
544+
def foo
545+
next unless need_next?
548546
549-
it 'registers an offense and corrects only the last guard clause' do
550-
expect_offense(<<~RUBY)
551-
def foo
552-
next if foo?
553-
next if bar?
554-
^^^^^^^^^^^^ Add empty line after guard clause.
555-
foobar
556-
end
557-
RUBY
547+
end_this!
548+
end
549+
RUBY
550+
end
551+
552+
it 'registers an offense and corrects only the last guard clause' do
553+
expect_offense(<<~RUBY)
554+
def foo
555+
next if foo?
556+
next if bar?
557+
^^^^^^^^^^^^ Add empty line after guard clause.
558+
foobar
559+
end
560+
RUBY
558561

559-
expect_correction(<<~RUBY)
560-
def foo
561-
next if foo?
562-
next if bar?
562+
expect_correction(<<~RUBY)
563+
def foo
564+
next if foo?
565+
next if bar?
563566
564-
foobar
565-
end
566-
RUBY
567+
foobar
568+
end
569+
RUBY
570+
end
567571
end
568572

569573
it 'registers no offenses using heredoc with `and return` before guard condition with empty line' do

spec/rubocop/cop/layout/empty_lines_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
RUBY
3131
end
3232

33-
# FIXME: https://github.com/ruby/prism/issues/2515
34-
it 'does not register an offense for empty lines in a string', broken_on: :prism do
33+
it 'does not register an offense for empty lines in a string' do
3534
expect_no_offenses(<<~RUBY)
3635
result = "test
3736
@@ -41,8 +40,7 @@
4140
RUBY
4241
end
4342

44-
# FIXME: https://github.com/ruby/prism/issues/2512
45-
it 'does not register an offense for heredocs with empty lines inside', broken_on: :prism do
43+
it 'does not register an offense for heredocs with empty lines inside' do
4644
expect_no_offenses(<<~RUBY)
4745
str = <<-TEXT
4846
line 1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy