Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove should_not raise_error from core/array/fill_spec.rb #1042

Merged
merged 1 commit into from
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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