summaryrefslogtreecommitdiff
path: root/spec/ruby/core/enumerator/next_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/enumerator/next_spec.rb')
-rw-r--r--spec/ruby/core/enumerator/next_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/ruby/core/enumerator/next_spec.rb b/spec/ruby/core/enumerator/next_spec.rb
index 3e9ed8b015..a5e01a399d 100644
--- a/spec/ruby/core/enumerator/next_spec.rb
+++ b/spec/ruby/core/enumerator/next_spec.rb
@@ -24,4 +24,15 @@ describe "Enumerator#next" do
@enum.rewind
@enum.next.should == 1
end
+
+ it "restarts the enumerator if an exception terminated a previous iteration" do
+ exception = StandardError.new
+ enum = Enumerator.new do
+ raise exception
+ end
+
+ result = 2.times.map { enum.next rescue $! }
+
+ result.should == [exception, exception]
+ end
end