diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-24 07:05:42 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-24 07:05:42 +0000 |
commit | 1af390b1ea11acd00558e8d86d23d17d328e580d (patch) | |
tree | a53928cac73ffba4ecc27505fdedf00a5c025c6e /test | |
parent | cc6e6de22f08a857174813cc90e8e378c71fbef9 (diff) |
* enumerator.c: Optimize Lazy#zip when passed only arrays
[Bug #7706]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_lazy_enumerator.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb index b626bc4753..3d05d333fb 100644 --- a/test/ruby/test_lazy_enumerator.rb +++ b/test/ruby/test_lazy_enumerator.rb @@ -272,6 +272,20 @@ class TestLazyEnumerator < Test::Unit::TestCase assert_equal([[1, 'a', 'a'], [2, 'b', 'b'], [3, 'c', 'c']]*3, zip.flat_map{zip}.force, bug7696) end + def test_zip_lazy_on_args + zip = Step.new(1..2).lazy.zip(42..Float::INFINITY) + assert_equal [[1, 42], [2, 43]], zip.force + end + + def test_zip_efficient_on_array_args + ary = [42, :foo] + %i[to_enum enum_for lazy each].each do |forbid| + ary.define_singleton_method(forbid){ fail "#{forbid} was called"} + end + zip = Step.new(1..2).lazy.zip(ary) + assert_equal [[1, 42], [2, :foo]], zip.force + end + def test_take_rewound bug7696 = '[ruby-core:51470]' e=(1..42).lazy.take(2) |