Fix lazy enumerator with index size

Fixes [Bug #17889]
This commit is contained in:
Jeremy Evans 2021-05-27 13:29:24 -07:00
parent 029169bc5b
commit fd8991f797
Notes: git 2021-05-28 06:18:06 +09:00
2 changed files with 10 additions and 1 deletions

View File

@ -2700,8 +2700,13 @@ lazy_with_index_proc(VALUE proc_entry, struct MEMO* result, VALUE memos, long me
return result;
}
static VALUE
lazy_with_index_size(VALUE proc, VALUE receiver) {
return receiver;
}
static const lazyenum_funcs lazy_with_index_funcs = {
lazy_with_index_proc, 0,
lazy_with_index_proc, lazy_with_index_size,
};
/*

View File

@ -682,4 +682,8 @@ EOS
ary = (0..Float::INFINITY).lazy.with_index.take(2).to_a
assert_equal([[0, 0], [1, 1]], ary)
end
def test_with_index_size
assert_equal(3, Enumerator::Lazy.new([1, 2, 3], 3){|y, v| y << v}.with_index.size)
end
end