From da7976235fbc2986925969646071bebe3702e49f Mon Sep 17 00:00:00 2001 From: eregon Date: Thu, 21 Feb 2019 15:38:59 +0000 Subject: Update to ruby/spec@7a16e01 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/core/array/each_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'spec/ruby/core/array') diff --git a/spec/ruby/core/array/each_spec.rb b/spec/ruby/core/array/each_spec.rb index ad8a5ad3d5..256647d61e 100644 --- a/spec/ruby/core/array/each_spec.rb +++ b/spec/ruby/core/array/each_spec.rb @@ -27,6 +27,22 @@ describe "Array#each" do b.should == [2, nil, 4] end + it "yields elements added to the end of the array by the block" do + a = [2] + iterated = [] + a.each { |x| iterated << x; x.times { a << 0 } } + + iterated.should == [2, 0, 0] + end + + it "does not yield elements deleted from the end of the array" do + a = [2, 3, 1] + iterated = [] + a.each { |x| iterated << x; a.delete_at(2) if x == 3 } + + iterated.should == [2, 3] + end + it_behaves_like :enumeratorize, :each it_behaves_like :enumeratorized_with_origin_size, :each, [1,2,3] end -- cgit v1.2.3