mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@9be7c7e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aeeaadaad0
commit
b53cf149ad
246 changed files with 9108 additions and 548 deletions
|
@ -111,6 +111,31 @@ describe "Array#reject!" do
|
|||
lambda { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "does not truncate the array is the block raises an exception" do
|
||||
a = [1, 2, 3]
|
||||
begin
|
||||
a.reject! { raise StandardError, 'Oops' }
|
||||
rescue
|
||||
end
|
||||
|
||||
a.should == [1, 2, 3]
|
||||
end
|
||||
|
||||
ruby_version_is "2.4" do
|
||||
it "only removes elements for which the block returns true, keeping the element which raised an error." do
|
||||
a = [1, 2, 3, 4]
|
||||
begin
|
||||
a.reject! do |x|
|
||||
return true if x == 2
|
||||
raise raise StandardError, 'Oops' if x == 3
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
||||
a.should == [1, 3, 4]
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like :enumeratorize, :reject!
|
||||
it_behaves_like :enumeratorized_with_origin_size, :reject!, [1,2,3]
|
||||
it_behaves_like :delete_if, :reject!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue