diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-15 02:00:30 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-15 02:00:30 +0000 |
commit | d18dc746986e1611a11c46c0f728fd9f08bbdfc7 (patch) | |
tree | 1baf00c7ff4586fc0aff90c9f31c498736c6ab98 /test/ruby/test_lazy_enumerator.rb | |
parent | c037f1f61696d64cbe42b6bb4bd1f0558578146d (diff) | |
download | ruby-d18dc746986e1611a11c46c0f728fd9f08bbdfc7.tar.gz |
* enumerator.c (lazy_cycle): add Enumerable::Lazy#cycle.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_lazy_enumerator.rb')
-rw-r--r-- | test/ruby/test_lazy_enumerator.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb index 6b4d49a041..1c0096f88c 100644 --- a/test/ruby/test_lazy_enumerator.rb +++ b/test/ruby/test_lazy_enumerator.rb @@ -184,6 +184,16 @@ class TestLazyEnumerator < Test::Unit::TestCase assert_equal([4, 5], (1..Float::INFINITY).lazy.drop(3).take(2).to_a) end + def test_cycle + a = Step.new(1..3) + assert_equal("1", a.cycle(2).map(&:to_s).first) + assert_equal(3, a.current) + assert_equal("1", a.lazy.cycle(2).map(&:to_s).first) + assert_equal(1, a.current) + assert_equal("1", a.lazy.cycle(2, &:to_s).first) + assert_equal(1, a.current) + end + def test_force assert_equal([1, 2, 3], (1..Float::INFINITY).lazy.take(3).force) end |