Skip to content

Commit 571bbfa

Browse files
committed
Run ruby ../mspec/tool/remove_old_guards.rb 2.6
1 parent 2c444ac commit 571bbfa

File tree

133 files changed

+2447
-3085
lines changed

Some content is hidden

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

133 files changed

+2447
-3085
lines changed

core/array/difference_spec.rb

+13-15
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22
require_relative 'fixtures/classes'
33
require_relative 'shared/difference'
44

5-
ruby_version_is "2.6" do
6-
describe "Array#difference" do
7-
it_behaves_like :array_binary_difference, :difference
5+
describe "Array#difference" do
6+
it_behaves_like :array_binary_difference, :difference
87

9-
it "returns a copy when called without any parameter" do
10-
x = [1, 2, 3, 2]
11-
x.difference.should == x
12-
x.difference.should_not equal x
13-
end
8+
it "returns a copy when called without any parameter" do
9+
x = [1, 2, 3, 2]
10+
x.difference.should == x
11+
x.difference.should_not equal x
12+
end
1413

15-
it "does not return subclass instances for Array subclasses" do
16-
ArraySpecs::MyArray[1, 2, 3].difference.should be_an_instance_of(Array)
17-
end
14+
it "does not return subclass instances for Array subclasses" do
15+
ArraySpecs::MyArray[1, 2, 3].difference.should be_an_instance_of(Array)
16+
end
1817

19-
it "accepts multiple arguments" do
20-
x = [1, 2, 3, 1]
21-
x.difference([], [0, 1], [3, 4], [3]).should == [2]
22-
end
18+
it "accepts multiple arguments" do
19+
x = [1, 2, 3, 1]
20+
x.difference([], [0, 1], [3, 4], [3]).should == [2]
2321
end
2422
end

core/array/element_set_spec.rb

+29-31
Original file line numberDiff line numberDiff line change
@@ -445,41 +445,39 @@ def obj.to_ary() [1, 2, 3] end
445445
end
446446
end
447447

448-
ruby_version_is "2.6" do
449-
describe "Array#[]= with [m..]" do
450-
it "just sets the section defined by range to nil even if the rhs is nil" do
451-
a = [1, 2, 3, 4, 5]
452-
a[eval("(2..)")] = nil
453-
a.should == [1, 2, nil]
454-
end
448+
describe "Array#[]= with [m..]" do
449+
it "just sets the section defined by range to nil even if the rhs is nil" do
450+
a = [1, 2, 3, 4, 5]
451+
a[eval("(2..)")] = nil
452+
a.should == [1, 2, nil]
453+
end
455454

456-
it "just sets the section defined by range to nil if m and n < 0 and the rhs is nil" do
457-
a = [1, 2, 3, 4, 5]
458-
a[eval("(-3..)")] = nil
459-
a.should == [1, 2, nil]
460-
end
455+
it "just sets the section defined by range to nil if m and n < 0 and the rhs is nil" do
456+
a = [1, 2, 3, 4, 5]
457+
a[eval("(-3..)")] = nil
458+
a.should == [1, 2, nil]
459+
end
461460

462-
it "replaces the section defined by range" do
463-
a = [6, 5, 4, 3, 2, 1]
464-
a[eval("(3...)")] = 9
465-
a.should == [6, 5, 4, 9]
466-
a[eval("(2..)")] = [7, 7, 7]
467-
a.should == [6, 5, 7, 7, 7]
468-
end
461+
it "replaces the section defined by range" do
462+
a = [6, 5, 4, 3, 2, 1]
463+
a[eval("(3...)")] = 9
464+
a.should == [6, 5, 4, 9]
465+
a[eval("(2..)")] = [7, 7, 7]
466+
a.should == [6, 5, 7, 7, 7]
467+
end
469468

470-
it "replaces the section if m and n < 0" do
471-
a = [1, 2, 3, 4, 5]
472-
a[eval("(-3..)")] = [7, 8, 9]
473-
a.should == [1, 2, 7, 8, 9]
474-
end
469+
it "replaces the section if m and n < 0" do
470+
a = [1, 2, 3, 4, 5]
471+
a[eval("(-3..)")] = [7, 8, 9]
472+
a.should == [1, 2, 7, 8, 9]
473+
end
475474

476-
it "inserts at the end if m > the array size" do
477-
a = [1, 2, 3]
478-
a[eval("(3..)")] = [4]
479-
a.should == [1, 2, 3, 4]
480-
a[eval("(5..)")] = [6]
481-
a.should == [1, 2, 3, 4, nil, 6]
482-
end
475+
it "inserts at the end if m > the array size" do
476+
a = [1, 2, 3]
477+
a[eval("(3..)")] = [4]
478+
a.should == [1, 2, 3, 4]
479+
a[eval("(5..)")] = [6]
480+
a.should == [1, 2, 3, 4, nil, 6]
483481
end
484482
end
485483

core/array/fill_spec.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,11 @@ def obj.<=>(rhs); rhs == self ? 0 : nil end
316316
-> { [].fill('a', obj..obj) }.should raise_error(TypeError)
317317
end
318318

319-
ruby_version_is "2.6" do
320-
it "works with endless ranges" do
321-
[1, 2, 3, 4].fill('x', eval("(1..)")).should == [1, 'x', 'x', 'x']
322-
[1, 2, 3, 4].fill('x', eval("(3...)")).should == [1, 2, 3, 'x']
323-
[1, 2, 3, 4].fill(eval("(1..)")) { |x| x + 2 }.should == [1, 3, 4, 5]
324-
[1, 2, 3, 4].fill(eval("(3...)")) { |x| x + 2 }.should == [1, 2, 3, 5]
325-
end
319+
it "works with endless ranges" do
320+
[1, 2, 3, 4].fill('x', eval("(1..)")).should == [1, 'x', 'x', 'x']
321+
[1, 2, 3, 4].fill('x', eval("(3...)")).should == [1, 2, 3, 'x']
322+
[1, 2, 3, 4].fill(eval("(1..)")) { |x| x + 2 }.should == [1, 3, 4, 5]
323+
[1, 2, 3, 4].fill(eval("(3...)")) { |x| x + 2 }.should == [1, 2, 3, 5]
326324
end
327325

328326
ruby_version_is "2.7" do

core/array/filter_spec.rb

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
require_relative '../../spec_helper'
22
require_relative 'shared/select'
33

4-
ruby_version_is "2.6" do
5-
describe "Array#filter" do
6-
it_behaves_like :array_select, :filter
7-
end
8-
9-
describe "Array#filter!" do
10-
it "returns nil if no changes were made in the array" do
11-
[1, 2, 3].filter! { true }.should be_nil
12-
end
4+
describe "Array#filter" do
5+
it_behaves_like :array_select, :filter
6+
end
137

14-
it_behaves_like :keep_if, :filter!
8+
describe "Array#filter!" do
9+
it "returns nil if no changes were made in the array" do
10+
[1, 2, 3].filter! { true }.should be_nil
1511
end
12+
13+
it_behaves_like :keep_if, :filter!
1614
end

core/array/shared/slice.rb

+10-12
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,16 @@ def to.to_int() -2 end
521521
-> { "hello".send(@method, 0..bignum_value) }.should raise_error(RangeError)
522522
end
523523

524-
ruby_version_is "2.6" do
525-
it "can accept endless ranges" do
526-
a = [0, 1, 2, 3, 4, 5]
527-
a.send(@method, eval("(2..)")).should == [2, 3, 4, 5]
528-
a.send(@method, eval("(2...)")).should == [2, 3, 4, 5]
529-
a.send(@method, eval("(-2..)")).should == [4, 5]
530-
a.send(@method, eval("(-2...)")).should == [4, 5]
531-
a.send(@method, eval("(9..)")).should == nil
532-
a.send(@method, eval("(9...)")).should == nil
533-
a.send(@method, eval("(-9..)")).should == nil
534-
a.send(@method, eval("(-9...)")).should == nil
535-
end
524+
it "can accept endless ranges" do
525+
a = [0, 1, 2, 3, 4, 5]
526+
a.send(@method, eval("(2..)")).should == [2, 3, 4, 5]
527+
a.send(@method, eval("(2...)")).should == [2, 3, 4, 5]
528+
a.send(@method, eval("(-2..)")).should == [4, 5]
529+
a.send(@method, eval("(-2...)")).should == [4, 5]
530+
a.send(@method, eval("(9..)")).should == nil
531+
a.send(@method, eval("(9...)")).should == nil
532+
a.send(@method, eval("(-9..)")).should == nil
533+
a.send(@method, eval("(-9...)")).should == nil
536534
end
537535

538536
ruby_version_is "2.7" do

core/array/slice_spec.rb

+16-18
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,22 @@ def to.to_int() -2 end
154154
-> { ArraySpecs.frozen_array.slice!(0, 0) }.should raise_error(FrozenError)
155155
end
156156

157-
ruby_version_is "2.6" do
158-
it "works with endless ranges" do
159-
a = [1, 2, 3]
160-
a.slice!(eval("(1..)")).should == [2, 3]
161-
a.should == [1]
162-
163-
a = [1, 2, 3]
164-
a.slice!(eval("(2...)")).should == [3]
165-
a.should == [1, 2]
166-
167-
a = [1, 2, 3]
168-
a.slice!(eval("(-2..)")).should == [2, 3]
169-
a.should == [1]
170-
171-
a = [1, 2, 3]
172-
a.slice!(eval("(-1...)")).should == [3]
173-
a.should == [1, 2]
174-
end
157+
it "works with endless ranges" do
158+
a = [1, 2, 3]
159+
a.slice!(eval("(1..)")).should == [2, 3]
160+
a.should == [1]
161+
162+
a = [1, 2, 3]
163+
a.slice!(eval("(2...)")).should == [3]
164+
a.should == [1, 2]
165+
166+
a = [1, 2, 3]
167+
a.slice!(eval("(-2..)")).should == [2, 3]
168+
a.should == [1]
169+
170+
a = [1, 2, 3]
171+
a.slice!(eval("(-1...)")).should == [3]
172+
a.should == [1, 2]
175173
end
176174

177175
ruby_version_is "2.7" do

core/array/to_h_spec.rb

+35-37
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,41 @@
3939
[[:a, 1], [:b, 2]].to_h[:c].should be_nil
4040
end
4141

42-
ruby_version_is "2.6" do
43-
context "with block" do
44-
it "converts [key, value] pairs returned by the block to a Hash" do
45-
[:a, :b].to_h { |k| [k, k.to_s] }.should == { a: 'a', b: 'b' }
46-
end
47-
48-
it "raises ArgumentError if block returns longer or shorter array" do
49-
-> do
50-
[:a, :b].to_h { |k| [k, k.to_s, 1] }
51-
end.should raise_error(ArgumentError, /wrong array length at 0/)
52-
53-
-> do
54-
[:a, :b].to_h { |k| [k] }
55-
end.should raise_error(ArgumentError, /wrong array length at 0/)
56-
end
57-
58-
it "raises TypeError if block returns something other than Array" do
59-
-> do
60-
[:a, :b].to_h { |k| "not-array" }
61-
end.should raise_error(TypeError, /wrong element type String at 0/)
62-
end
63-
64-
it "coerces returned pair to Array with #to_ary" do
65-
x = mock('x')
66-
x.stub!(:to_ary).and_return([:b, 'b'])
67-
68-
[:a].to_h { |k| x }.should == { :b => 'b' }
69-
end
70-
71-
it "does not coerce returned pair to Array with #to_a" do
72-
x = mock('x')
73-
x.stub!(:to_a).and_return([:b, 'b'])
74-
75-
-> do
76-
[:a].to_h { |k| x }
77-
end.should raise_error(TypeError, /wrong element type MockObject at 0/)
78-
end
42+
context "with block" do
43+
it "converts [key, value] pairs returned by the block to a Hash" do
44+
[:a, :b].to_h { |k| [k, k.to_s] }.should == { a: 'a', b: 'b' }
45+
end
46+
47+
it "raises ArgumentError if block returns longer or shorter array" do
48+
-> do
49+
[:a, :b].to_h { |k| [k, k.to_s, 1] }
50+
end.should raise_error(ArgumentError, /wrong array length at 0/)
51+
52+
-> do
53+
[:a, :b].to_h { |k| [k] }
54+
end.should raise_error(ArgumentError, /wrong array length at 0/)
55+
end
56+
57+
it "raises TypeError if block returns something other than Array" do
58+
-> do
59+
[:a, :b].to_h { |k| "not-array" }
60+
end.should raise_error(TypeError, /wrong element type String at 0/)
61+
end
62+
63+
it "coerces returned pair to Array with #to_ary" do
64+
x = mock('x')
65+
x.stub!(:to_ary).and_return([:b, 'b'])
66+
67+
[:a].to_h { |k| x }.should == { :b => 'b' }
68+
end
69+
70+
it "does not coerce returned pair to Array with #to_a" do
71+
x = mock('x')
72+
x.stub!(:to_a).and_return([:b, 'b'])
73+
74+
-> do
75+
[:a].to_h { |k| x }
76+
end.should raise_error(TypeError, /wrong element type MockObject at 0/)
7977
end
8078
end
8179
end

core/array/union_spec.rb

+12-14
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@
66
it_behaves_like :array_binary_union, :|
77
end
88

9-
ruby_version_is "2.6" do
10-
describe "Array#union" do
11-
it_behaves_like :array_binary_union, :union
9+
describe "Array#union" do
10+
it_behaves_like :array_binary_union, :union
1211

13-
it "returns unique elements when given no argument" do
14-
x = [1, 2, 3, 2]
15-
x.union.should == [1, 2, 3]
16-
end
12+
it "returns unique elements when given no argument" do
13+
x = [1, 2, 3, 2]
14+
x.union.should == [1, 2, 3]
15+
end
1716

18-
it "does not return subclass instances for Array subclasses" do
19-
ArraySpecs::MyArray[1, 2, 3].union.should be_an_instance_of(Array)
20-
end
17+
it "does not return subclass instances for Array subclasses" do
18+
ArraySpecs::MyArray[1, 2, 3].union.should be_an_instance_of(Array)
19+
end
2120

22-
it "accepts multiple arguments" do
23-
x = [1, 2, 3]
24-
x.union(x, x, x, x, [3, 4], x).should == [1, 2, 3, 4]
25-
end
21+
it "accepts multiple arguments" do
22+
x = [1, 2, 3]
23+
x.union(x, x, x, x, [3, 4], x).should == [1, 2, 3, 4]
2624
end
2725
end

core/array/values_at_spec.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ def to.to_int() -2 end
6161
ArraySpecs::MyArray[1, 2, 3].values_at(0, 1..2, 1).should be_an_instance_of(Array)
6262
end
6363

64-
ruby_version_is "2.6" do
65-
it "works when given endless ranges" do
66-
[1, 2, 3, 4].values_at(eval("(1..)")).should == [2, 3, 4]
67-
[1, 2, 3, 4].values_at(eval("(3...)")).should == [4]
68-
end
64+
it "works when given endless ranges" do
65+
[1, 2, 3, 4].values_at(eval("(1..)")).should == [2, 3, 4]
66+
[1, 2, 3, 4].values_at(eval("(3...)")).should == [4]
6967
end
7068

7169
ruby_version_is "2.7" do

core/binding/source_location_spec.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
require_relative '../../spec_helper'
22
require_relative 'fixtures/location'
33

4-
ruby_version_is "2.6" do
5-
describe "Binding#source_location" do
6-
it "returns an [file, line] pair" do
7-
b = BindingSpecs::LocationMethod::TEST_BINDING
8-
b.source_location.should == [BindingSpecs::LocationMethod::FILE_PATH, 4]
9-
end
4+
describe "Binding#source_location" do
5+
it "returns an [file, line] pair" do
6+
b = BindingSpecs::LocationMethod::TEST_BINDING
7+
b.source_location.should == [BindingSpecs::LocationMethod::FILE_PATH, 4]
108
end
119
end

0 commit comments

Comments
 (0)