Skip to content

Commit 301d316

Browse files
committed
Remove various other ruby version guards
1 parent cfeed31 commit 301d316

6 files changed

Lines changed: 63 additions & 99 deletions

File tree

test/rbs/runtime_prototype_test.rb

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -775,74 +775,72 @@ class StructDirectInherited < ::Struct[untyped]
775775
end
776776
end
777777

778-
if RUBY_VERSION >= '3.2'
779-
class DataInherit < Data.define(:foo, :bar, :baz?)
780-
end
781-
DataConst = Data.define(:foo, :bar)
782-
class DataDirectInherit < Data
783-
end
778+
class DataInherit < Data.define(:foo, :bar, :baz?)
779+
end
780+
DataConst = Data.define(:foo, :bar)
781+
class DataDirectInherit < Data
782+
end
784783

785-
def test_data
786-
SignatureManager.new do |manager|
787-
manager.build do |env|
788-
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::DataInherit"], env: env, merge: false)
789-
assert_write p.decls, <<~RBS
790-
module RBS
791-
class RuntimePrototypeTest < ::Test::Unit::TestCase
792-
class DataInherit < ::Data
793-
def self.new: (untyped foo, untyped bar, untyped `baz?`) -> instance
794-
| (foo: untyped, bar: untyped, baz?: untyped) -> instance
784+
def test_data
785+
SignatureManager.new do |manager|
786+
manager.build do |env|
787+
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::DataInherit"], env: env, merge: false)
788+
assert_write p.decls, <<~RBS
789+
module RBS
790+
class RuntimePrototypeTest < ::Test::Unit::TestCase
791+
class DataInherit < ::Data
792+
def self.new: (untyped foo, untyped bar, untyped `baz?`) -> instance
793+
| (foo: untyped, bar: untyped, baz?: untyped) -> instance
795794
796-
def self.[]: (untyped foo, untyped bar, untyped `baz?`) -> instance
797-
| (foo: untyped, bar: untyped, baz?: untyped) -> instance
795+
def self.[]: (untyped foo, untyped bar, untyped `baz?`) -> instance
796+
| (foo: untyped, bar: untyped, baz?: untyped) -> instance
798797
799-
def self.members: () -> [ :foo, :bar, :baz? ]
798+
def self.members: () -> [ :foo, :bar, :baz? ]
800799
801-
def members: () -> [ :foo, :bar, :baz? ]
800+
def members: () -> [ :foo, :bar, :baz? ]
802801
803-
attr_reader foo: untyped
802+
attr_reader foo: untyped
804803
805-
attr_reader bar: untyped
804+
attr_reader bar: untyped
806805
807-
attr_reader baz?: untyped
808-
end
806+
attr_reader baz?: untyped
809807
end
810808
end
811-
RBS
809+
end
810+
RBS
812811

813-
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::DataConst"], env: env, merge: false)
814-
assert_write p.decls, <<~RBS
815-
module RBS
816-
class RuntimePrototypeTest < ::Test::Unit::TestCase
817-
class DataConst < ::Data
818-
def self.new: (untyped foo, untyped bar) -> instance
819-
| (foo: untyped, bar: untyped) -> instance
812+
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::DataConst"], env: env, merge: false)
813+
assert_write p.decls, <<~RBS
814+
module RBS
815+
class RuntimePrototypeTest < ::Test::Unit::TestCase
816+
class DataConst < ::Data
817+
def self.new: (untyped foo, untyped bar) -> instance
818+
| (foo: untyped, bar: untyped) -> instance
820819
821-
def self.[]: (untyped foo, untyped bar) -> instance
822-
| (foo: untyped, bar: untyped) -> instance
820+
def self.[]: (untyped foo, untyped bar) -> instance
821+
| (foo: untyped, bar: untyped) -> instance
823822
824-
def self.members: () -> [ :foo, :bar ]
823+
def self.members: () -> [ :foo, :bar ]
825824
826-
def members: () -> [ :foo, :bar ]
825+
def members: () -> [ :foo, :bar ]
827826
828-
attr_reader foo: untyped
827+
attr_reader foo: untyped
829828
830-
attr_reader bar: untyped
831-
end
829+
attr_reader bar: untyped
832830
end
833831
end
834-
RBS
832+
end
833+
RBS
835834

836-
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::DataDirectInherit"], env: env, merge: false)
837-
assert_write p.decls, <<~RBS
838-
module RBS
839-
class RuntimePrototypeTest < ::Test::Unit::TestCase
840-
class DataDirectInherit < ::Data
841-
end
835+
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::DataDirectInherit"], env: env, merge: false)
836+
assert_write p.decls, <<~RBS
837+
module RBS
838+
class RuntimePrototypeTest < ::Test::Unit::TestCase
839+
class DataDirectInherit < ::Data
842840
end
843841
end
844-
RBS
845-
end
842+
end
843+
RBS
846844
end
847845
end
848846
end

test/rbs/test/runtime_test_test.rb

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

5-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
6-
75
class RBS::Test::RuntimeTestTest < Test::Unit::TestCase
86
omit_on_truffle_ruby! "`rbs test` relies on `TracePoint` `:end` event, which is not supported on TruffleRuby"
97
omit_on_jruby! "`rbs test` relies on `TracePoint` `:end` event, which is not supported on JRuby"

test/stdlib/Regexp_test.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ def test_compile
5151
assert_send_type '(string, int | string | bool | nil) -> Regexp',
5252
Regexp, :compile, pattern, options
5353

54-
# In older versions of ruby, `Regexp.{new,compile}` could take an additional third argument,
55-
# which indicated "no encoding". Due to weirdnesses with how keyword arguments are passed
56-
# around in Ruby, along with how `compile` is registered internally, the `timeout: _ToF?`
57-
# argument is interpreted as this optional third argument in older versions. So, to prevent
58-
# any issues, this `next` skips it. Note that this issue doesn't occur in `test_initialize`
59-
# because the implicit argument passing isn't done.
60-
next if RUBY_VERSION < '3.3'
61-
6254
with_float(12.34).and_nil do |timeout|
6355
assert_send_type '(string, int | string | bool | nil, timeout: _ToF?) -> Regexp',
6456
Regexp, :compile, pattern, options, timeout: timeout
@@ -149,8 +141,6 @@ def (toregexp = BlankSlate.new).to_regexp = /a/
149141
end
150142

151143
def test_timeout
152-
omit_if RUBY_VERSION < '3.2'
153-
154144
begin
155145
old_timeout = Regexp.timeout
156146

@@ -167,8 +157,6 @@ def test_timeout
167157
end
168158

169159
def test_timeout=
170-
omit_if RUBY_VERSION < '3.2'
171-
172160
begin
173161
old_timeout = Regexp.timeout
174162

test/stdlib/RubyVM_test.rb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ def test_of
2121
RubyVM::AbstractSyntaxTree, :of, method(:test_of)
2222
end
2323

24-
if RUBY_VERSION >= '3.2'
25-
def test_node_id_for_backtrace_location
26-
assert_send_type "(::Thread::Backtrace::Location backtrace_location) -> ::Integer",
27-
RubyVM::AbstractSyntaxTree, :node_id_for_backtrace_location, caller_locations[0]
28-
end
24+
def test_node_id_for_backtrace_location
25+
assert_send_type "(::Thread::Backtrace::Location backtrace_location) -> ::Integer",
26+
RubyVM::AbstractSyntaxTree, :node_id_for_backtrace_location, caller_locations[0]
2927
end
3028
end
3129

@@ -66,16 +64,14 @@ def test_locations
6664
end
6765
end
6866

69-
if RUBY_VERSION >= '3.2'
70-
def test_tokens
71-
assert_send_type "() -> ::Array[[ ::Integer, ::Symbol, ::String, [ ::Integer, ::Integer, ::Integer, ::Integer ] ]]?",
72-
RubyVM::AbstractSyntaxTree.parse("1 + 2", keep_tokens: true), :tokens
73-
end
67+
def test_tokens
68+
assert_send_type "() -> ::Array[[ ::Integer, ::Symbol, ::String, [ ::Integer, ::Integer, ::Integer, ::Integer ] ]]?",
69+
RubyVM::AbstractSyntaxTree.parse("1 + 2", keep_tokens: true), :tokens
70+
end
7471

75-
def test_all_tokens
76-
assert_send_type "() -> ::Array[[ ::Integer, ::Symbol, ::String, [ ::Integer, ::Integer, ::Integer, ::Integer ] ]]?",
77-
RubyVM::AbstractSyntaxTree.parse("1 + 2", keep_tokens: true), :all_tokens
78-
end
72+
def test_all_tokens
73+
assert_send_type "() -> ::Array[[ ::Integer, ::Symbol, ::String, [ ::Integer, ::Integer, ::Integer, ::Integer ] ]]?",
74+
RubyVM::AbstractSyntaxTree.parse("1 + 2", keep_tokens: true), :all_tokens
7975
end
8076

8177
def test_children

test/stdlib/String_test.rb

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,6 @@ def test_b
323323
end
324324

325325
def test_byteindex
326-
omit_if RUBY_VERSION < '3.2'
327-
328326
with_string('e').and /e/ do |pattern|
329327
assert_send_type '(Regexp | string) -> Integer',
330328
'hello', :byteindex, pattern
@@ -341,8 +339,6 @@ def test_byteindex
341339
end
342340

343341
def test_byterindex
344-
omit_if RUBY_VERSION < '3.2'
345-
346342
with_string('e').and /e/ do |pattern|
347343
assert_send_type '(Regexp | string) -> Integer',
348344
'hello', :byterindex, pattern
@@ -389,32 +385,22 @@ def test_byteslice
389385
end
390386

391387
def test_bytesplice
392-
omit_if(RUBY_VERSION < '3.2', 'String#bytesplice was added in 3.2')
393-
394-
# In 3.3 and onwards (and backported to 3.2.16), the return type is `self`. This variable
395-
# is in case the test suite is run in a version under 3.2.16; tests for the variants only
396-
# supported in 3.3 and onwards use `self`. If we ever stop supporting 3.2, we can remove this.
397-
398388
with_string ', world! :-D' do |string|
399389
assert_send_type "(Integer, Integer, string) -> String",
400390
+'hello', :bytesplice, 1, 2, string
401391

402-
if RUBY_VERSION >= "3.3.0"
403-
with_int 1 do |start|
404-
assert_send_type '(int, Integer, string, Integer, Integer) -> String',
405-
+'hello', :bytesplice, start, 2, string, 3, 4
406-
end
392+
with_int 1 do |start|
393+
assert_send_type '(int, Integer, string, Integer, Integer) -> String',
394+
+'hello', :bytesplice, start, 2, string, 3, 4
407395
end
408396

409397
with_range with_int(1).and_nil, with_int(2).and_nil do |range|
410398
assert_send_type "(range[int?], string) -> String",
411399
+'hello', :bytesplice, range, string
412400

413-
if RUBY_VERSION >= '3.3.0'
414-
with_range with_int(3).and_nil, with_int(4).and_nil do |string_range|
415-
assert_send_type '(range[int?], string, range[int?]) -> String',
416-
+'hello', :bytesplice, range, string, string_range
417-
end
401+
with_range with_int(3).and_nil, with_int(4).and_nil do |string_range|
402+
assert_send_type '(range[int?], string, range[int?]) -> String',
403+
+'hello', :bytesplice, range, string, string_range
418404
end
419405
end
420406
end
@@ -574,7 +560,6 @@ def test_count
574560
end
575561

576562
def test_dedup
577-
omit_if RUBY_VERSION < '3.2.0'
578563
test_uneg :dedup
579564
end
580565

test/stdlib/Warning_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require_relative "test_helper"
22

3-
WARNING_CATEGORIES = %i[deprecated experimental]
4-
WARNING_CATEGORIES << :performance if RUBY_VERSION >= '3.3'
3+
WARNING_CATEGORIES = %i[deprecated experimental performance]
54

65
class WarningSingletonTest < Test::Unit::TestCase
76
include TestHelper

0 commit comments

Comments
 (0)