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

@ -37,7 +37,7 @@ describe :array_collect, shared: true do
it "raises an ArgumentError when no block and with arguments" do
a = [1, 2, 3]
lambda {
-> {
a.send(@method, :foo)
}.should raise_error(ArgumentError)
end
@ -111,21 +111,21 @@ describe :array_collect_b, shared: true do
describe "when frozen" do
it "raises a #{frozen_error_class}" do
lambda { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
-> { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
end
it "raises a #{frozen_error_class} when empty" do
lambda { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
-> { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
end
it "raises a #{frozen_error_class} when calling #each on the returned Enumerator" do
enumerator = ArraySpecs.frozen_array.send(@method)
lambda { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
-> { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
end
it "raises a #{frozen_error_class} when calling #each on the returned Enumerator when empty" do
enumerator = ArraySpecs.empty_frozen_array.send(@method)
lambda { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
-> { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
end
end

View file

@ -27,7 +27,7 @@ describe :array_binary_difference, shared: true do
it "raises a TypeError if the argument cannot be coerced to an Array by calling #to_ary" do
obj = mock('not an array')
lambda { [1, 2, 3].send(@method, obj) }.should raise_error(TypeError)
-> { [1, 2, 3].send(@method, obj) }.should raise_error(TypeError)
end
it "does not return subclass instance for Array subclasses" do

View file

@ -55,7 +55,7 @@ describe :array_inspect, shared: true do
obj.should_receive(:inspect).and_return(obj)
obj.should_receive(:to_s).and_raise(Exception)
lambda { [obj].send(@method) }.should raise_error(Exception)
-> { [obj].send(@method) }.should raise_error(Exception)
end
it "represents a recursive element with '[...]'" do

View file

@ -49,13 +49,13 @@ describe :array_join_with_default_separator, shared: true do
it "raises a NoMethodError if an element does not respond to #to_str, #to_ary, or #to_s" do
obj = mock('o')
class << obj; undef :to_s; end
lambda { [1, obj].send(@method) }.should raise_error(NoMethodError)
-> { [1, obj].send(@method) }.should raise_error(NoMethodError)
end
it "raises an ArgumentError when the Array is recursive" do
lambda { ArraySpecs.recursive_array.send(@method) }.should raise_error(ArgumentError)
lambda { ArraySpecs.head_recursive_array.send(@method) }.should raise_error(ArgumentError)
lambda { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError)
-> { ArraySpecs.recursive_array.send(@method) }.should raise_error(ArgumentError)
-> { ArraySpecs.head_recursive_array.send(@method) }.should raise_error(ArgumentError)
-> { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError)
end
it "taints the result if the Array is tainted and non-empty" do
@ -109,7 +109,7 @@ describe :array_join_with_default_separator, shared: true do
it "fails for arrays with incompatibly-encoded strings" do
ary_utf8_bad_binary = ArraySpecs.array_with_utf8_and_binary_strings
lambda { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError)
-> { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError)
end
end

View file

@ -37,23 +37,23 @@ describe :keep_if, shared: true do
describe "with truthy block" do
it "keeps elements after any exception" do
lambda { @frozen.send(@method) { true } }.should raise_error(Exception)
-> { @frozen.send(@method) { true } }.should raise_error(Exception)
@frozen.should == @origin
end
it "raises a #{frozen_error_class}" do
lambda { @frozen.send(@method) { true } }.should raise_error(frozen_error_class)
-> { @frozen.send(@method) { true } }.should raise_error(frozen_error_class)
end
end
describe "with falsy block" do
it "keeps elements after any exception" do
lambda { @frozen.send(@method) { false } }.should raise_error(Exception)
-> { @frozen.send(@method) { false } }.should raise_error(Exception)
@frozen.should == @origin
end
it "raises a #{frozen_error_class}" do
lambda { @frozen.send(@method) { false } }.should raise_error(frozen_error_class)
-> { @frozen.send(@method) { false } }.should raise_error(frozen_error_class)
end
end
end

View file

@ -27,7 +27,7 @@ describe :array_push, shared: true do
end
it "raises a #{frozen_error_class} on a frozen array" do
lambda { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
lambda { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
-> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
end
end

View file

@ -53,7 +53,7 @@ describe :array_replace, shared: true do
end
it "raises a #{frozen_error_class} on a frozen array" do
lambda {
-> {
ArraySpecs.frozen_array.send(@method, ArraySpecs.frozen_array)
}.should raise_error(frozen_error_class)
end

View file

@ -266,10 +266,10 @@ describe :array_slice, shared: true do
a.send(@method, 1..0).should == []
a.send(@method, 1...0).should == []
lambda { a.send(@method, "a" .. "b") }.should raise_error(TypeError)
lambda { a.send(@method, "a" ... "b") }.should raise_error(TypeError)
lambda { a.send(@method, from .. "b") }.should raise_error(TypeError)
lambda { a.send(@method, from ... "b") }.should raise_error(TypeError)
-> { a.send(@method, "a" .. "b") }.should raise_error(TypeError)
-> { a.send(@method, "a" ... "b") }.should raise_error(TypeError)
-> { a.send(@method, from .. "b") }.should raise_error(TypeError)
-> { a.send(@method, from ... "b") }.should raise_error(TypeError)
end
it "returns the same elements as [m..n] and [m...n] with Range subclasses" do
@ -441,19 +441,19 @@ describe :array_slice, shared: true do
array = [1, 2, 3, 4, 5, 6]
obj = mock('large value')
obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000)
lambda { array.send(@method, obj) }.should raise_error(RangeError)
-> { array.send(@method, obj) }.should raise_error(RangeError)
obj = 8e19
lambda { array.send(@method, obj) }.should raise_error(RangeError)
-> { array.send(@method, obj) }.should raise_error(RangeError)
end
it "raises a RangeError when the length is out of range of Fixnum" do
array = [1, 2, 3, 4, 5, 6]
obj = mock('large value')
obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000)
lambda { array.send(@method, 1, obj) }.should raise_error(RangeError)
-> { array.send(@method, 1, obj) }.should raise_error(RangeError)
obj = 8e19
lambda { array.send(@method, 1, obj) }.should raise_error(RangeError)
-> { array.send(@method, 1, obj) }.should raise_error(RangeError)
end
end

View file

@ -36,11 +36,11 @@ describe :array_unshift, shared: true do
end
it "raises a #{frozen_error_class} on a frozen array when the array is modified" do
lambda { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
-> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
end
# see [ruby-core:23666]
it "raises a #{frozen_error_class} on a frozen array when the array would not be modified" do
lambda { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
end
end