mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@875a09e
This commit is contained in:
parent
a06301b103
commit
5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions
|
@ -30,7 +30,7 @@ describe "Array#flatten" do
|
|||
|
||||
it "raises a TypeError when the passed Object can't be converted to an Integer" do
|
||||
obj = mock("Not converted")
|
||||
lambda { [ 1, 2, [3, [4, 5] ] ].flatten(obj) }.should raise_error(TypeError)
|
||||
-> { [ 1, 2, [3, [4, 5] ] ].flatten(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not call flatten on elements" do
|
||||
|
@ -46,13 +46,13 @@ describe "Array#flatten" do
|
|||
it "raises an ArgumentError on recursive arrays" do
|
||||
x = []
|
||||
x << x
|
||||
lambda { x.flatten }.should raise_error(ArgumentError)
|
||||
-> { x.flatten }.should raise_error(ArgumentError)
|
||||
|
||||
x = []
|
||||
y = []
|
||||
x << y
|
||||
y << x
|
||||
lambda { x.flatten }.should raise_error(ArgumentError)
|
||||
-> { x.flatten }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "flattens any element which responds to #to_ary, using the return value of said method" do
|
||||
|
@ -106,7 +106,7 @@ describe "Array#flatten" do
|
|||
|
||||
it "raises a TypeError if #to_ary does not return an Array" do
|
||||
@obj.should_receive(:to_ary).and_return(1)
|
||||
lambda { [@obj].flatten }.should raise_error(TypeError)
|
||||
-> { [@obj].flatten }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
|
@ -135,7 +135,7 @@ describe "Array#flatten" do
|
|||
it "calls #to_ary if not defined when #respond_to_missing? returns true" do
|
||||
def @obj.respond_to_missing?(name, priv) ScratchPad << name; true end
|
||||
|
||||
lambda { [@obj].flatten }.should raise_error(NoMethodError)
|
||||
-> { [@obj].flatten }.should raise_error(NoMethodError)
|
||||
ScratchPad.recorded.should == [:to_ary]
|
||||
end
|
||||
|
||||
|
@ -226,7 +226,7 @@ describe "Array#flatten!" do
|
|||
|
||||
it "raises a TypeError when the passed Object can't be converted to an Integer" do
|
||||
obj = mock("Not converted")
|
||||
lambda { [ 1, 2, [3, [4, 5] ] ].flatten!(obj) }.should raise_error(TypeError)
|
||||
-> { [ 1, 2, [3, [4, 5] ] ].flatten!(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not call flatten! on elements" do
|
||||
|
@ -242,13 +242,13 @@ describe "Array#flatten!" do
|
|||
it "raises an ArgumentError on recursive arrays" do
|
||||
x = []
|
||||
x << x
|
||||
lambda { x.flatten! }.should raise_error(ArgumentError)
|
||||
-> { x.flatten! }.should raise_error(ArgumentError)
|
||||
|
||||
x = []
|
||||
y = []
|
||||
x << y
|
||||
y << x
|
||||
lambda { x.flatten! }.should raise_error(ArgumentError)
|
||||
-> { x.flatten! }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "flattens any elements which responds to #to_ary, using the return value of said method" do
|
||||
|
@ -273,12 +273,12 @@ describe "Array#flatten!" do
|
|||
it "raises a #{frozen_error_class} on frozen arrays when the array is modified" do
|
||||
nested_ary = [1, 2, []]
|
||||
nested_ary.freeze
|
||||
lambda { nested_ary.flatten! }.should raise_error(frozen_error_class)
|
||||
-> { nested_ary.flatten! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
# see [ruby-core:23663]
|
||||
it "raises a #{frozen_error_class} on frozen arrays when the array would not be modified" do
|
||||
lambda { ArraySpecs.frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
lambda { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue