1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-07-27 12:40:09 +02:00
parent a06301b103
commit 5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions

View file

@ -11,10 +11,10 @@ describe "Array.new" do
end
it "raises an ArgumentError if passed 3 or more arguments" do
lambda do
-> do
[1, 2].send :initialize, 1, 'x', true
end.should raise_error(ArgumentError)
lambda do
-> do
[1, 2].send(:initialize, 1, 'x', true) {}
end.should raise_error(ArgumentError)
end
@ -26,7 +26,7 @@ describe "Array.new with no arguments" do
end
it "does not use the given block" do
lambda{ Array.new { raise } }.should_not raise_error
->{ Array.new { raise } }.should_not raise_error
end
end
@ -37,7 +37,7 @@ describe "Array.new with (array)" do
end
it "does not use the given block" do
lambda{ Array.new([1, 2]) { raise } }.should_not raise_error
->{ Array.new([1, 2]) { raise } }.should_not raise_error
end
it "calls #to_ary to convert the value to an array" do
@ -54,7 +54,7 @@ describe "Array.new with (array)" do
end
it "raises a TypeError if an Array type argument and a default object" do
lambda { Array.new([1, 2], 1) }.should raise_error(TypeError)
-> { Array.new([1, 2], 1) }.should raise_error(TypeError)
end
end
@ -74,12 +74,12 @@ describe "Array.new with (size, object=nil)" do
end
it "raises an ArgumentError if size is negative" do
lambda { Array.new(-1, :a) }.should raise_error(ArgumentError)
lambda { Array.new(-1) }.should raise_error(ArgumentError)
-> { Array.new(-1, :a) }.should raise_error(ArgumentError)
-> { Array.new(-1) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if size is too large" do
lambda { Array.new(fixnum_max+1) }.should raise_error(ArgumentError)
-> { Array.new(fixnum_max+1) }.should raise_error(ArgumentError)
end
it "calls #to_int to convert the size argument to an Integer when object is given" do
@ -97,7 +97,7 @@ describe "Array.new with (size, object=nil)" do
it "raises a TypeError if the size argument is not an Integer type" do
obj = mock('nonnumeric')
obj.stub!(:to_ary).and_return([1, 2])
lambda{ Array.new(obj, :a) }.should raise_error(TypeError)
->{ Array.new(obj, :a) }.should raise_error(TypeError)
end
it "yields the index of the element and sets the element to the value of the block" do
@ -105,7 +105,7 @@ describe "Array.new with (size, object=nil)" do
end
it "uses the block value instead of using the default value" do
lambda {
-> {
@result = Array.new(3, :obj) { |i| i.to_s }
}.should complain(/block supersedes default value argument/)
@result.should == ['0', '1', '2']