diff options
author | Yusuke Endoh <[email protected]> | 2021-04-21 13:02:29 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-21 13:02:29 +0900 |
commit | fb04c69418ceee696a114fe31279cf3a5ea16d30 (patch) | |
tree | 0f8d78e40d15172c80ec0853fb37ea755049394c /test/ruby/test_array.rb | |
parent | d427e3cd6f1b39624c9935ade25b4dcb334bee36 (diff) |
array.c (rb_ary_zip): take only as many as needed from an Enumerator (#4389)
[Bug #17814]
Notes
Notes:
Merged-By: mame <[email protected]>
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index bf6a728574..4a9863cc54 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -2735,6 +2735,17 @@ class TestArray < Test::Unit::TestCase assert_equal [[42, 1]], [42].zip(r), bug8153 end + def test_zip_with_enumerator + bug17814 = "ruby-core:103513" + + step = 0.step + e = Enumerator.produce { step.next } + a = %w(a b c) + assert_equal([["a", 0], ["b", 1], ["c", 2]], a.zip(e)) + assert_equal([["a", 3], ["b", 4], ["c", 5]], a.zip(e)) + assert_equal([["a", 6], ["b", 7], ["c", 8]], a.zip(e)) + end + def test_transpose assert_equal([[1, :a], [2, :b], [3, :c]], [[1, 2, 3], [:a, :b, :c]].transpose) |