Skip to content

Commit 0bc7078

Browse files
committed
Drop RUBY_VERSION guards because Ruby >= 3.1 is supported
1 parent bbef46d commit 0bc7078

File tree

12 files changed

+105
-169
lines changed

12 files changed

+105
-169
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gem "test-unit"
1010
gem "rspec"
1111
gem "rubocop"
1212
gem "rubocop-rubycw"
13-
gem "rubocop-on-rbs" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1')
13+
gem "rubocop-on-rbs"
1414
gem "json"
1515
gem "json-schema"
1616
gem "goodcheck"

lib/rbs/prototype/runtime.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,6 @@ def type_params(mod)
649649
end
650650

651651
def block_from_ast_of(method)
652-
return nil if RUBY_VERSION < '3.1'
653-
654652
begin
655653
ast = RubyVM::AbstractSyntaxTree.of(method)
656654
rescue ArgumentError

test/rbs/rb_prototype_test.rb

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -846,14 +846,8 @@ def test_duplicate_methods
846846

847847
rb = <<-'EOR'
848848
class C
849-
if RUBY_VERSION >= '2.7'
850-
def foo(x, y, z)
851-
do_something_27
852-
end
853-
else
854-
def foo(x, y, z)
855-
do_something
856-
end
849+
def foo(x, y, z)
850+
do_something_27
857851
end
858852
end
859853
EOR
@@ -1086,21 +1080,19 @@ def foo: (*untyped, **untyped) ?{ (?) -> untyped } -> nil
10861080
end
10871081
end
10881082

1089-
if RUBY_VERSION >= '3'
1090-
def test_endless_method_definition
1091-
parser = RB.new
1092-
rb = <<~'RUBY'
1083+
def test_endless_method_definition
1084+
parser = RB.new
1085+
rb = <<~'RUBY'
10931086
module M
10941087
def foo = 42
10951088
end
1096-
RUBY
1097-
parser.parse(rb)
1089+
RUBY
1090+
parser.parse(rb)
10981091

1099-
assert_write parser.decls, <<~RBS
1092+
assert_write parser.decls, <<~RBS
11001093
module M
11011094
def foo: () -> 42
11021095
end
1103-
RBS
1104-
end
1096+
RBS
11051097
end
11061098
end

test/rbs/runtime_prototype_test.rb

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -241,33 +241,6 @@ def test_decls_for_anonymous_class_or_module
241241
end
242242
end
243243

244-
if RUBY_VERSION >= '2.7' && RUBY_VERSION <= '3.0'
245-
class TestForArgumentForwarding
246-
eval <<~RUBY
247-
def foo(...)
248-
end
249-
RUBY
250-
end
251-
252-
def test_argument_forwarding
253-
SignatureManager.new do |manager|
254-
manager.build do |env|
255-
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::TestForArgumentForwarding"], env: env, merge: true)
256-
257-
assert_write p.decls, <<-EOF
258-
module RBS
259-
class RuntimePrototypeTest < ::Test::Unit::TestCase
260-
class TestForArgumentForwarding
261-
def foo: (*untyped) { (*untyped) -> untyped } -> untyped
262-
end
263-
end
264-
end
265-
EOF
266-
end
267-
end
268-
end
269-
end
270-
271244
module TestForOverrideModuleName
272245
module M
273246
def self.name() 'FakeNameM' end
@@ -389,35 +362,33 @@ def initialize: () -> void
389362
end
390363
end
391364

392-
if RUBY_VERSION >= '3.1' && RUBY_VERSION <= "3.3"
393-
class TestForYield
394-
def m1() yield end
395-
def m2() yield 42 end
396-
def m3() yield 42; yield 42, 43 end
397-
eval 'def m4() yield end'
398-
end
365+
class TestForYield
366+
def m1() yield end
367+
def m2() yield 42 end
368+
def m3() yield 42; yield 42, 43 end
369+
eval 'def m4() yield end'
370+
end
399371

400-
def test_for_yield
401-
SignatureManager.new do |manager|
402-
manager.build do |env|
403-
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::TestForYield"], env: env, merge: true)
372+
def test_for_yield
373+
SignatureManager.new do |manager|
374+
manager.build do |env|
375+
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::TestForYield"], env: env, merge: true)
404376

405-
assert_write p.decls, <<~RBS
406-
module RBS
407-
class RuntimePrototypeTest < ::Test::Unit::TestCase
408-
class TestForYield
409-
def m1: () { () -> untyped } -> untyped
377+
assert_write p.decls, <<~RBS
378+
module RBS
379+
class RuntimePrototypeTest < ::Test::Unit::TestCase
380+
class TestForYield
381+
def m1: () { () -> untyped } -> untyped
410382
411-
def m2: () { (untyped) -> untyped } -> untyped
383+
def m2: () { (untyped) -> untyped } -> untyped
412384
413-
def m3: () { (untyped, untyped) -> untyped } -> untyped
385+
def m3: () { (untyped, untyped) -> untyped } -> untyped
414386
415-
def m4: () -> untyped
416-
end
387+
def m4: () -> untyped
417388
end
418389
end
419-
RBS
420-
end
390+
end
391+
RBS
421392
end
422393
end
423394
end

test/rbs/test/hook_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
require "rbs/test"
44
require "logger"
55

6-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
7-
86
class RBS::Test::HookTest < Test::Unit::TestCase
97
class Example
108
def hello(x, y)

test/rbs/test/type_check_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
require "rbs/test"
44
require "logger"
55

6-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
7-
86
RSPEC_MOCK = -> { double('foo') }
97

108
class RBS::Test::TypeCheckTest < Test::Unit::TestCase

test/stdlib/Module_test.rb

Lines changed: 68 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -318,106 +318,98 @@ def self.bar; end
318318
end
319319

320320
def test_attr
321-
if RUBY_VERSION >= '3.0'
322-
mod = Module.new
323-
assert_send_type(
324-
"(*interned arg0) -> Array[Symbol]",
325-
mod, :attr, :foo
326-
)
327-
end
321+
mod = Module.new
322+
assert_send_type(
323+
"(*interned arg0) -> Array[Symbol]",
324+
mod, :attr, :foo
325+
)
328326
end
329327

330328
def test_attr_reader
331-
if RUBY_VERSION >= '3.0'
332-
mod = Module.new
329+
mod = Module.new
333330

334-
assert_send_type(
335-
"(Symbol) -> Array[Symbol]",
336-
mod, :attr_reader, :foo
337-
)
331+
assert_send_type(
332+
"(Symbol) -> Array[Symbol]",
333+
mod, :attr_reader, :foo
334+
)
338335

339-
assert_send_type(
340-
"(Symbol, Symbol) -> Array[Symbol]",
341-
mod, :attr_reader, :foo, :bar
342-
)
336+
assert_send_type(
337+
"(Symbol, Symbol) -> Array[Symbol]",
338+
mod, :attr_reader, :foo, :bar
339+
)
343340

344-
assert_send_type(
345-
"(String) -> Array[Symbol]",
346-
mod, :attr_reader, "foo"
347-
)
341+
assert_send_type(
342+
"(String) -> Array[Symbol]",
343+
mod, :attr_reader, "foo"
344+
)
348345

349-
assert_send_type(
350-
"(String, String) -> Array[Symbol]",
351-
mod, :attr_reader, "foo", "bar"
352-
)
346+
assert_send_type(
347+
"(String, String) -> Array[Symbol]",
348+
mod, :attr_reader, "foo", "bar"
349+
)
353350

354-
assert_send_type(
355-
"(Symbol, String) -> Array[Symbol]",
356-
mod, :attr_reader, :foo, "bar"
357-
)
358-
end
351+
assert_send_type(
352+
"(Symbol, String) -> Array[Symbol]",
353+
mod, :attr_reader, :foo, "bar"
354+
)
359355
end
360356

361357
def test_attr_writer
362-
if RUBY_VERSION >= '3.0'
363-
mod = Module.new
358+
mod = Module.new
364359

365-
assert_send_type(
366-
"(Symbol) -> Array[Symbol]",
367-
mod, :attr_writer, :foo
368-
)
360+
assert_send_type(
361+
"(Symbol) -> Array[Symbol]",
362+
mod, :attr_writer, :foo
363+
)
369364

370-
assert_send_type(
371-
"(Symbol, Symbol) -> Array[Symbol]",
372-
mod, :attr_writer, :foo, :bar
373-
)
365+
assert_send_type(
366+
"(Symbol, Symbol) -> Array[Symbol]",
367+
mod, :attr_writer, :foo, :bar
368+
)
374369

375-
assert_send_type(
376-
"(String) -> Array[Symbol]",
377-
mod, :attr_writer, "foo"
378-
)
370+
assert_send_type(
371+
"(String) -> Array[Symbol]",
372+
mod, :attr_writer, "foo"
373+
)
379374

380-
assert_send_type(
381-
"(String, String) -> Array[Symbol]",
382-
mod, :attr_writer, "foo", "bar"
383-
)
375+
assert_send_type(
376+
"(String, String) -> Array[Symbol]",
377+
mod, :attr_writer, "foo", "bar"
378+
)
384379

385-
assert_send_type(
386-
"(Symbol, String) -> Array[Symbol]",
387-
mod, :attr_writer, :foo, "bar"
388-
)
389-
end
380+
assert_send_type(
381+
"(Symbol, String) -> Array[Symbol]",
382+
mod, :attr_writer, :foo, "bar"
383+
)
390384
end
391385

392386
def test_attr_accessor
393-
if RUBY_VERSION >= '3.0'
394-
mod = Module.new
387+
mod = Module.new
395388

396-
assert_send_type(
397-
"(Symbol) -> Array[Symbol]",
398-
mod, :attr_accessor, :foo
399-
)
389+
assert_send_type(
390+
"(Symbol) -> Array[Symbol]",
391+
mod, :attr_accessor, :foo
392+
)
400393

401-
assert_send_type(
402-
"(Symbol, Symbol) -> Array[Symbol]",
403-
mod, :attr_accessor, :foo, :bar
404-
)
394+
assert_send_type(
395+
"(Symbol, Symbol) -> Array[Symbol]",
396+
mod, :attr_accessor, :foo, :bar
397+
)
405398

406-
assert_send_type(
407-
"(String) -> Array[Symbol]",
408-
mod, :attr_accessor, "foo"
409-
)
399+
assert_send_type(
400+
"(String) -> Array[Symbol]",
401+
mod, :attr_accessor, "foo"
402+
)
410403

411-
assert_send_type(
412-
"(String, String) -> Array[Symbol]",
413-
mod, :attr_accessor, "foo", "bar"
414-
)
404+
assert_send_type(
405+
"(String, String) -> Array[Symbol]",
406+
mod, :attr_accessor, "foo", "bar"
407+
)
415408

416-
assert_send_type(
417-
"(Symbol, String) -> Array[Symbol]",
418-
mod, :attr_accessor, :foo, "bar"
419-
)
420-
end
409+
assert_send_type(
410+
"(Symbol, String) -> Array[Symbol]",
411+
mod, :attr_accessor, :foo, "bar"
412+
)
421413
end
422414

423415
def test_set_temporary_name

test/stdlib/Net_HTTP_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ def test_get
1515
assert_send_type "(String, String) -> nil",
1616
Net::HTTP, :get_print, 'www.ruby-lang.org', '/en'
1717
assert_send_type "(URI::Generic, Hash[String, String]) -> nil",
18-
Net::HTTP, :get_print, URI("https://www.ruby-lang.org"), {"Accept" => "text/html"} if RUBY_VERSION >= '3.0'
18+
Net::HTTP, :get_print, URI("https://www.ruby-lang.org"), {"Accept" => "text/html"}
1919
assert_send_type "(URI::Generic, Hash[Symbol, String]) -> nil",
20-
Net::HTTP, :get_print, URI("https://www.ruby-lang.org"), {Accept: "text/html"} if RUBY_VERSION >= '3.0'
20+
Net::HTTP, :get_print, URI("https://www.ruby-lang.org"), {Accept: "text/html"}
2121
assert_send_type "(URI::Generic) -> String",
2222
Net::HTTP, :get, URI("https://www.ruby-lang.org")
2323
assert_send_type "(String, String) -> String",
2424
Net::HTTP, :get, 'www.ruby-lang.org', '/en'
2525
assert_send_type "(URI::Generic, Hash[String, String]) -> String",
26-
Net::HTTP, :get, URI("https://www.ruby-lang.org"), {"Accept" => "text/html"} if RUBY_VERSION >= '3.0'
26+
Net::HTTP, :get, URI("https://www.ruby-lang.org"), {"Accept" => "text/html"}
2727
assert_send_type "(URI::Generic, Hash[Symbol, String]) -> String",
28-
Net::HTTP, :get, URI("https://www.ruby-lang.org"), {Accept: "text/html"} if RUBY_VERSION >= '3.0'
28+
Net::HTTP, :get, URI("https://www.ruby-lang.org"), {Accept: "text/html"}
2929
assert_send_type "(URI::Generic) -> Net::HTTPResponse",
3030
Net::HTTP, :get_response, URI("https://www.ruby-lang.org")
3131
assert_send_type "(String, String) -> Net::HTTPResponse",
3232
Net::HTTP, :get_response, 'www.ruby-lang.org', '/en'
3333
assert_send_type "(URI::Generic, Hash[String, String]) -> Net::HTTPResponse",
34-
Net::HTTP, :get_response, URI("https://www.ruby-lang.org"), {"Accept" => "text/html"} if RUBY_VERSION >= '3.0'
34+
Net::HTTP, :get_response, URI("https://www.ruby-lang.org"), {"Accept" => "text/html"}
3535
assert_send_type "(URI::Generic, Hash[Symbol, String]) -> Net::HTTPResponse",
36-
Net::HTTP, :get_response, URI("https://www.ruby-lang.org"), {Accept: "text/html"} if RUBY_VERSION >= '3.0'
36+
Net::HTTP, :get_response, URI("https://www.ruby-lang.org"), {Accept: "text/html"}
3737
ensure
3838
$stdout = STDOUT
3939
end

test/stdlib/Ractor_test.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
require_relative "test_helper"
22

3-
if RUBY_VERSION < '3'
4-
warn 'Ractor is not available on Ruby 2🐫 Skip the test'
5-
return
6-
end
7-
83
class RactorSingletonTest < Test::Unit::TestCase
94
include TestHelper
105

0 commit comments

Comments
 (0)