diff options
author | Benoit Daloze <eregontp@gmail.com> | 2022-03-28 17:47:04 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2022-03-28 17:47:04 +0200 |
commit | 8db4f25bf4327f169902afd9ea8f4b03b65656f0 (patch) | |
tree | ad61b99fb2d5ebfe9c07de8c2b5885e80d20b8e1 /spec/ruby/core/enumerator/lazy/with_index_spec.rb | |
parent | ae650f0372e10cea4d695769b1fcdc23a76fdf17 (diff) |
Update to ruby/spec@aaf998f
Diffstat (limited to 'spec/ruby/core/enumerator/lazy/with_index_spec.rb')
-rw-r--r-- | spec/ruby/core/enumerator/lazy/with_index_spec.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/ruby/core/enumerator/lazy/with_index_spec.rb b/spec/ruby/core/enumerator/lazy/with_index_spec.rb index 3a59ba4116..b6dbe554d9 100644 --- a/spec/ruby/core/enumerator/lazy/with_index_spec.rb +++ b/spec/ruby/core/enumerator/lazy/with_index_spec.rb @@ -26,5 +26,13 @@ ruby_version_is "2.7" do (0..Float::INFINITY).lazy.with_index { |i, idx| result << [i * 2, idx] }.first(3) result.should == [[0,0],[2,1],[4,2]] end + + it "resets after a new call to each" do + enum = (0..2).lazy.with_index.map { |i, idx| [i, idx] } + result = [] + enum.each { |i, idx| result << [i, idx] } + enum.each { |i, idx| result << [i, idx] } + result.should == [[0,0], [1,1], [2,2], [0,0], [1,1], [2,2]] + end end end |