summaryrefslogtreecommitdiff
path: root/test/ruby/test_enumerator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_enumerator.rb')
-rw-r--r--test/ruby/test_enumerator.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index e70a783a00..fe8a573b2b 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -141,6 +141,28 @@ class TestEnumerator < Test::Unit::TestCase
assert_raise(StopIteration) { e.peek }
end
+ def test_peek_modify
+ o = Object.new
+ def o.each
+ yield 1,2
+ end
+ e = o.to_enum
+ a = e.peek
+ a << 3
+ assert_equal([1,2], e.peek)
+ end
+
+ def test_peek_values_modify
+ o = Object.new
+ def o.each
+ yield 1,2
+ end
+ e = o.to_enum
+ a = e.peek_values
+ a << 3
+ assert_equal([1,2], e.peek)
+ end
+
def test_next_after_stopiteration
a = [1]
e = a.each