Skip to content

Commit 53a192b

Browse files
committed
Remove guards for Ruby 3.1
1 parent b114cbf commit 53a192b

File tree

85 files changed

+1779
-2742
lines changed

Some content is hidden

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

85 files changed

+1779
-2742
lines changed

core/array/intersect_spec.rb

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,63 @@
22
require_relative 'fixtures/classes'
33

44
describe 'Array#intersect?' do
5-
ruby_version_is '3.1' do # https://bugs.ruby-lang.org/issues/15198
6-
describe 'when at least one element in two Arrays is the same' do
7-
it 'returns true' do
8-
[1, 2].intersect?([2, 3, 4]).should == true
9-
[2, 3, 4].intersect?([1, 2]).should == true
10-
end
5+
describe 'when at least one element in two Arrays is the same' do
6+
it 'returns true' do
7+
[1, 2].intersect?([2, 3, 4]).should == true
8+
[2, 3, 4].intersect?([1, 2]).should == true
119
end
10+
end
1211

13-
describe 'when there are no elements in common between two Arrays' do
14-
it 'returns false' do
15-
[0, 1, 2].intersect?([3, 4]).should == false
16-
[3, 4].intersect?([0, 1, 2]).should == false
17-
[3, 4].intersect?([]).should == false
18-
[].intersect?([0, 1, 2]).should == false
19-
end
12+
describe 'when there are no elements in common between two Arrays' do
13+
it 'returns false' do
14+
[0, 1, 2].intersect?([3, 4]).should == false
15+
[3, 4].intersect?([0, 1, 2]).should == false
16+
[3, 4].intersect?([]).should == false
17+
[].intersect?([0, 1, 2]).should == false
2018
end
19+
end
2120

22-
it "tries to convert the passed argument to an Array using #to_ary" do
23-
obj = mock('[1,2,3]')
24-
obj.should_receive(:to_ary).and_return([1, 2, 3])
21+
it "tries to convert the passed argument to an Array using #to_ary" do
22+
obj = mock('[1,2,3]')
23+
obj.should_receive(:to_ary).and_return([1, 2, 3])
2524

26-
[1, 2].intersect?(obj).should == true
27-
end
25+
[1, 2].intersect?(obj).should == true
26+
end
2827

29-
it "determines equivalence between elements in the sense of eql?" do
30-
obj1 = mock('1')
31-
obj2 = mock('2')
32-
obj1.stub!(:hash).and_return(0)
33-
obj2.stub!(:hash).and_return(0)
34-
obj1.stub!(:eql?).and_return(true)
35-
obj2.stub!(:eql?).and_return(true)
28+
it "determines equivalence between elements in the sense of eql?" do
29+
obj1 = mock('1')
30+
obj2 = mock('2')
31+
obj1.stub!(:hash).and_return(0)
32+
obj2.stub!(:hash).and_return(0)
33+
obj1.stub!(:eql?).and_return(true)
34+
obj2.stub!(:eql?).and_return(true)
3635

37-
[obj1].intersect?([obj2]).should == true
36+
[obj1].intersect?([obj2]).should == true
3837

39-
obj1 = mock('3')
40-
obj2 = mock('4')
41-
obj1.stub!(:hash).and_return(0)
42-
obj2.stub!(:hash).and_return(0)
43-
obj1.stub!(:eql?).and_return(false)
44-
obj2.stub!(:eql?).and_return(false)
38+
obj1 = mock('3')
39+
obj2 = mock('4')
40+
obj1.stub!(:hash).and_return(0)
41+
obj2.stub!(:hash).and_return(0)
42+
obj1.stub!(:eql?).and_return(false)
43+
obj2.stub!(:eql?).and_return(false)
4544

46-
[obj1].intersect?([obj2]).should == false
47-
end
45+
[obj1].intersect?([obj2]).should == false
46+
end
4847

49-
it "does not call to_ary on array subclasses" do
50-
[5, 6].intersect?(ArraySpecs::ToAryArray[1, 2, 5, 6]).should == true
51-
end
48+
it "does not call to_ary on array subclasses" do
49+
[5, 6].intersect?(ArraySpecs::ToAryArray[1, 2, 5, 6]).should == true
50+
end
5251

53-
it "properly handles an identical item even when its #eql? isn't reflexive" do
54-
x = mock('x')
55-
x.stub!(:hash).and_return(42)
56-
x.stub!(:eql?).and_return(false) # Stubbed for clarity and latitude in implementation; not actually sent by MRI.
52+
it "properly handles an identical item even when its #eql? isn't reflexive" do
53+
x = mock('x')
54+
x.stub!(:hash).and_return(42)
55+
x.stub!(:eql?).and_return(false) # Stubbed for clarity and latitude in implementation; not actually sent by MRI.
5756

58-
[x].intersect?([x]).should == true
59-
end
57+
[x].intersect?([x]).should == true
58+
end
6059

61-
it "has semantic of !(a & b).empty?" do
62-
[].intersect?([]).should == false
63-
[nil].intersect?([nil]).should == true
64-
end
60+
it "has semantic of !(a & b).empty?" do
61+
[].intersect?([]).should == false
62+
[nil].intersect?([nil]).should == true
6563
end
6664
end

core/basicobject/instance_eval_spec.rb

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,11 @@ class B; end
141141
caller.get_constant_with_string(receiver).should == :singleton_class
142142
end
143143

144-
ruby_version_is ""..."3.1" do
145-
it "looks in the caller scope next" do
146-
receiver = BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::ReceiverScope::Receiver.new
147-
caller = BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::CallerScope::Caller.new
144+
it "looks in the receiver class next" do
145+
receiver = BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::ReceiverScope::Receiver.new
146+
caller = BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::CallerScope::Caller.new
148147

149-
caller.get_constant_with_string(receiver).should == :Caller
150-
end
151-
end
152-
153-
ruby_version_is "3.1" do
154-
it "looks in the receiver class next" do
155-
receiver = BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::ReceiverScope::Receiver.new
156-
caller = BasicObjectSpecs::InstEval::Constants::ConstantInReceiverClass::CallerScope::Caller.new
157-
158-
caller.get_constant_with_string(receiver).should == :Receiver
159-
end
148+
caller.get_constant_with_string(receiver).should == :Receiver
160149
end
161150

162151
it "looks in the caller class next" do

core/class/subclasses_spec.rb

Lines changed: 62 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,85 @@
11
require_relative '../../spec_helper'
22
require_relative '../module/fixtures/classes'
33

4-
ruby_version_is '3.1' do
5-
describe "Class#subclasses" do
6-
it "returns a list of classes directly inheriting from self" do
7-
assert_subclasses(ModuleSpecs::Parent, [ModuleSpecs::Child, ModuleSpecs::Child2])
8-
end
4+
describe "Class#subclasses" do
5+
it "returns a list of classes directly inheriting from self" do
6+
assert_subclasses(ModuleSpecs::Parent, [ModuleSpecs::Child, ModuleSpecs::Child2])
7+
end
98

10-
it "does not return included modules from the parent" do
11-
parent = Class.new
12-
child = Class.new(parent)
13-
mod = Module.new
14-
parent.include(mod)
9+
it "does not return included modules from the parent" do
10+
parent = Class.new
11+
child = Class.new(parent)
12+
mod = Module.new
13+
parent.include(mod)
1514

16-
assert_subclasses(parent, [child])
17-
end
18-
19-
it "does not return included modules from the child" do
20-
parent = Class.new
21-
child = Class.new(parent)
22-
mod = Module.new
23-
parent.include(mod)
15+
assert_subclasses(parent, [child])
16+
end
2417

25-
assert_subclasses(parent, [child])
26-
end
18+
it "does not return included modules from the child" do
19+
parent = Class.new
20+
child = Class.new(parent)
21+
mod = Module.new
22+
parent.include(mod)
2723

28-
it "does not return prepended modules from the parent" do
29-
parent = Class.new
30-
child = Class.new(parent)
31-
mod = Module.new
32-
parent.prepend(mod)
24+
assert_subclasses(parent, [child])
25+
end
3326

34-
assert_subclasses(parent, [child])
35-
end
27+
it "does not return prepended modules from the parent" do
28+
parent = Class.new
29+
child = Class.new(parent)
30+
mod = Module.new
31+
parent.prepend(mod)
3632

37-
it "does not return prepended modules from the child" do
38-
parent = Class.new
39-
child = Class.new(parent)
40-
mod = Module.new
41-
child.prepend(mod)
33+
assert_subclasses(parent, [child])
34+
end
4235

43-
assert_subclasses(parent, [child])
44-
end
36+
it "does not return prepended modules from the child" do
37+
parent = Class.new
38+
child = Class.new(parent)
39+
mod = Module.new
40+
child.prepend(mod)
4541

46-
it "does not return singleton classes" do
47-
a = Class.new
42+
assert_subclasses(parent, [child])
43+
end
4844

49-
a_obj = a.new
50-
def a_obj.force_singleton_class
51-
42
52-
end
45+
it "does not return singleton classes" do
46+
a = Class.new
5347

54-
a.subclasses.should_not include(a_obj.singleton_class)
48+
a_obj = a.new
49+
def a_obj.force_singleton_class
50+
42
5551
end
5652

57-
it "has 1 entry per module or class" do
58-
ModuleSpecs::Parent.subclasses.should == ModuleSpecs::Parent.subclasses.uniq
59-
end
53+
a.subclasses.should_not include(a_obj.singleton_class)
54+
end
55+
56+
it "has 1 entry per module or class" do
57+
ModuleSpecs::Parent.subclasses.should == ModuleSpecs::Parent.subclasses.uniq
58+
end
6059

61-
it "works when creating subclasses concurrently" do
62-
t = 16
63-
n = 1000
64-
go = false
65-
superclass = Class.new
66-
67-
threads = t.times.map do
68-
Thread.new do
69-
Thread.pass until go
70-
n.times.map do
71-
Class.new(superclass)
72-
end
60+
it "works when creating subclasses concurrently" do
61+
t = 16
62+
n = 1000
63+
go = false
64+
superclass = Class.new
65+
66+
threads = t.times.map do
67+
Thread.new do
68+
Thread.pass until go
69+
n.times.map do
70+
Class.new(superclass)
7371
end
7472
end
73+
end
7574

76-
go = true
77-
classes = threads.map(&:value)
75+
go = true
76+
classes = threads.map(&:value)
7877

79-
superclass.subclasses.size.should == t * n
80-
superclass.subclasses.each { |c| c.should be_kind_of(Class) }
81-
end
78+
superclass.subclasses.size.should == t * n
79+
superclass.subclasses.each { |c| c.should be_kind_of(Class) }
80+
end
8281

83-
def assert_subclasses(mod,subclasses)
84-
mod.subclasses.sort_by(&:inspect).should == subclasses.sort_by(&:inspect)
85-
end
82+
def assert_subclasses(mod,subclasses)
83+
mod.subclasses.sort_by(&:inspect).should == subclasses.sort_by(&:inspect)
8684
end
8785
end

core/dir/glob_spec.rb

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,15 @@
8989
Dir.glob('**/', File::FNM_DOTMATCH).sort.should == expected
9090
end
9191

92-
ruby_version_is ''...'3.1' do
93-
it "recursively matches files and directories in nested dot subdirectory with 'nested/**/*' from the current directory and option File::FNM_DOTMATCH" do
94-
expected = %w[
95-
nested/.
96-
nested/.dotsubir
97-
nested/.dotsubir/.
98-
nested/.dotsubir/.dotfile
99-
nested/.dotsubir/nondotfile
100-
]
101-
102-
Dir.glob('nested/**/*', File::FNM_DOTMATCH).sort.should == expected.sort
103-
end
104-
end
105-
106-
ruby_version_is '3.1' do
107-
it "recursively matches files and directories in nested dot subdirectory except . with 'nested/**/*' from the current directory and option File::FNM_DOTMATCH" do
108-
expected = %w[
109-
nested/.
110-
nested/.dotsubir
111-
nested/.dotsubir/.dotfile
112-
nested/.dotsubir/nondotfile
113-
]
92+
it "recursively matches files and directories in nested dot subdirectory except . with 'nested/**/*' from the current directory and option File::FNM_DOTMATCH" do
93+
expected = %w[
94+
nested/.
95+
nested/.dotsubir
96+
nested/.dotsubir/.dotfile
97+
nested/.dotsubir/nondotfile
98+
]
11499

115-
Dir.glob('nested/**/*', File::FNM_DOTMATCH).sort.should == expected.sort
116-
end
100+
Dir.glob('nested/**/*', File::FNM_DOTMATCH).sort.should == expected.sort
117101
end
118102

119103
# This is a separate case to check **/ coming after a constant
@@ -260,34 +244,31 @@
260244
Dir.glob('**/.*', base: "deeply/nested").sort.should == expected
261245
end
262246

263-
# < 3.1 include a "." entry for every dir: ["directory/.", "directory/structure/.", ...]
264-
ruby_version_is '3.1' do
265-
it "handles **/.* with base keyword argument and FNM_DOTMATCH" do
266-
expected = %w[
267-
.
268-
.dotfile.ext
269-
directory/structure/.ext
270-
].sort
247+
it "handles **/.* with base keyword argument and FNM_DOTMATCH" do
248+
expected = %w[
249+
.
250+
.dotfile.ext
251+
directory/structure/.ext
252+
].sort
271253

272-
Dir.glob('**/.*', File::FNM_DOTMATCH, base: "deeply/nested").sort.should == expected
273-
end
254+
Dir.glob('**/.*', File::FNM_DOTMATCH, base: "deeply/nested").sort.should == expected
255+
end
274256

275-
it "handles **/** with base keyword argument and FNM_DOTMATCH" do
276-
expected = %w[
277-
.
278-
.dotfile.ext
279-
directory
280-
directory/structure
281-
directory/structure/.ext
282-
directory/structure/bar
283-
directory/structure/baz
284-
directory/structure/file_one
285-
directory/structure/file_one.ext
286-
directory/structure/foo
287-
].sort
288-
289-
Dir.glob('**/**', File::FNM_DOTMATCH, base: "deeply/nested").sort.should == expected
290-
end
257+
it "handles **/** with base keyword argument and FNM_DOTMATCH" do
258+
expected = %w[
259+
.
260+
.dotfile.ext
261+
directory
262+
directory/structure
263+
directory/structure/.ext
264+
directory/structure/bar
265+
directory/structure/baz
266+
directory/structure/file_one
267+
directory/structure/file_one.ext
268+
directory/structure/foo
269+
].sort
270+
271+
Dir.glob('**/**', File::FNM_DOTMATCH, base: "deeply/nested").sort.should == expected
291272
end
292273

293274
it "handles **/*pattern* with base keyword argument and FNM_DOTMATCH" do

0 commit comments

Comments
 (0)