1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_lazy_enumerator.rb: test for cycle chain

* test/ruby/test_lazy_enumerator.rb (test_cycle_chain): more test for
  infinite sequence.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-07-27 08:07:21 +00:00
parent 1d7ebc5c5e
commit 76ff1d90c8

View file

@ -285,6 +285,12 @@ class TestLazyEnumerator < Test::Unit::TestCase
assert_equal(3, a.current)
end
def test_cycle_chain
a = Step.new(1..3)
assert_equal([2,2,2,2,2,2,2,2,2,2], a.lazy.cycle.select {|x| x == 2}.take(10).force)
assert_equal([2,2,2,2,2,2,2,2,2,2], a.lazy.select {|x| x == 2}.cycle.take(10).force)
end
def test_force
assert_equal([1, 2, 3], (1..Float::INFINITY).lazy.take(3).force)
end