diff options
-rw-r--r-- | test/ruby/test_enumerator.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index 1d583e4fee..981d8bd434 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -616,5 +616,14 @@ class TestEnumerator < Test::Unit::TestCase assert_equal 5, 'hello'.each_char.size assert_equal 5, 'hello'.each_codepoint.size end + + def test_peek_for_enumerator_objects + e = 2.times + assert_equal(0, e.peek) + e.next + assert_equal(1, e.peek) + e.next + assert_raise(StopIteration) { e.peek } + end end |