Skip to content

Commit

Permalink
Merge pull request #1042 from ytjmt/754-array-fill
Browse files Browse the repository at this point in the history
Remove should_not raise_error from core/array/fill_spec.rb
  • Loading branch information
andrykonchin authored May 25, 2023
2 parents 87469a5 + 7220099 commit 4419d36
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions core/array/fill_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@
end

it "raises an ArgumentError if 4 or more arguments are passed when no block given" do
-> { [].fill('a') }.should_not raise_error(ArgumentError)

-> { [].fill('a', 1) }.should_not raise_error(ArgumentError)

-> { [].fill('a', 1, 2) }.should_not raise_error(ArgumentError)
[].fill('a').should == []
[].fill('a', 1).should == []
[].fill('a', 1, 2).should == [nil, 'a', 'a']
-> { [].fill('a', 1, 2, true) }.should raise_error(ArgumentError)
end

Expand All @@ -65,11 +63,9 @@
end

it "raises an ArgumentError if 3 or more arguments are passed when a block given" do
-> { [].fill() {|i|} }.should_not raise_error(ArgumentError)

-> { [].fill(1) {|i|} }.should_not raise_error(ArgumentError)

-> { [].fill(1, 2) {|i|} }.should_not raise_error(ArgumentError)
[].fill() {|i|}.should == []
[].fill(1) {|i|}.should == []
[].fill(1, 2) {|i|}.should == [nil, nil, nil]
-> { [].fill(1, 2, true) {|i|} }.should raise_error(ArgumentError)
end

Expand Down Expand Up @@ -213,23 +209,23 @@

# See: https://blade.ruby-lang.org/ruby-core/17481
it "does not raise an exception if the given length is negative and its absolute value does not exceed the index" do
-> { [1, 2, 3, 4].fill('a', 3, -1)}.should_not raise_error(ArgumentError)
-> { [1, 2, 3, 4].fill('a', 3, -2)}.should_not raise_error(ArgumentError)
-> { [1, 2, 3, 4].fill('a', 3, -3)}.should_not raise_error(ArgumentError)
[1, 2, 3, 4].fill('a', 3, -1).should == [1, 2, 3, 4]
[1, 2, 3, 4].fill('a', 3, -2).should == [1, 2, 3, 4]
[1, 2, 3, 4].fill('a', 3, -3).should == [1, 2, 3, 4]

-> { [1, 2, 3, 4].fill(3, -1, &@never_passed)}.should_not raise_error(ArgumentError)
-> { [1, 2, 3, 4].fill(3, -2, &@never_passed)}.should_not raise_error(ArgumentError)
-> { [1, 2, 3, 4].fill(3, -3, &@never_passed)}.should_not raise_error(ArgumentError)
[1, 2, 3, 4].fill(3, -1, &@never_passed).should == [1, 2, 3, 4]
[1, 2, 3, 4].fill(3, -2, &@never_passed).should == [1, 2, 3, 4]
[1, 2, 3, 4].fill(3, -3, &@never_passed).should == [1, 2, 3, 4]
end

it "does not raise an exception even if the given length is negative and its absolute value exceeds the index" do
-> { [1, 2, 3, 4].fill('a', 3, -4)}.should_not raise_error(ArgumentError)
-> { [1, 2, 3, 4].fill('a', 3, -5)}.should_not raise_error(ArgumentError)
-> { [1, 2, 3, 4].fill('a', 3, -10000)}.should_not raise_error(ArgumentError)
[1, 2, 3, 4].fill('a', 3, -4).should == [1, 2, 3, 4]
[1, 2, 3, 4].fill('a', 3, -5).should == [1, 2, 3, 4]
[1, 2, 3, 4].fill('a', 3, -10000).should == [1, 2, 3, 4]

-> { [1, 2, 3, 4].fill(3, -4, &@never_passed)}.should_not raise_error(ArgumentError)
-> { [1, 2, 3, 4].fill(3, -5, &@never_passed)}.should_not raise_error(ArgumentError)
-> { [1, 2, 3, 4].fill(3, -10000, &@never_passed)}.should_not raise_error(ArgumentError)
[1, 2, 3, 4].fill(3, -4, &@never_passed).should == [1, 2, 3, 4]
[1, 2, 3, 4].fill(3, -5, &@never_passed).should == [1, 2, 3, 4]
[1, 2, 3, 4].fill(3, -10000, &@never_passed).should == [1, 2, 3, 4]
end

it "tries to convert the second and third arguments to Integers using #to_int" do
Expand Down

0 comments on commit 4419d36

Please sign in to comment.