aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/array
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-03 16:19:40 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-03 16:19:40 +0000
commitb53cf149ad8d7c46572e4567ca949b4f82ebb22c (patch)
treeee5032bcb38573dade8ba2c46acbcc0d5f3ddfe3 /spec/ruby/core/array
parentaeeaadaad08038217440c1e9e7c5ca126d7dc633 (diff)
downloadruby-b53cf149ad8d7c46572e4567ca949b4f82ebb22c.tar.gz
Update to ruby/spec@9be7c7e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/array')
-rw-r--r--spec/ruby/core/array/reject_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/ruby/core/array/reject_spec.rb b/spec/ruby/core/array/reject_spec.rb
index 77835ef5cd..e6e5e851b6 100644
--- a/spec/ruby/core/array/reject_spec.rb
+++ b/spec/ruby/core/array/reject_spec.rb
@@ -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!