Use of "iterable" Type May Need Re-Evaluation Across the Repo #784
Conversation
Codecov Report
@@ Coverage Diff @@
## main #784 +/- ##
============================================
+ Coverage 79.37% 79.48% +0.10%
+ Complexity 1407 1406 -1
============================================
Files 160 160
Lines 3477 3470 -7
============================================
- Hits 2760 2758 -2
+ Misses 717 712 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Nevay
left a comment
There was a problem hiding this comment.
Failing test:
assert(isEmpty((fn() => yield from [])()));| $generator = gen(); | ||
| foreach ($generator as $value) { | ||
| } | ||
| $value=isEmpty($generator) ? true : false; |
|
Another failing test: $generator = (fn() => yield from [1, 2])();
$generator->next();
assert(!isEmpty($generator)); |
|
$generator = (fn() => yield from [1, 2])(); This is a non empty generator case and hence isEmpty() will return false. Hence the test case is passing |
Currently it returns true ( What is the expected result for an exhausted rewindable iterator? $iterator = new ArrayIterator([1]);
$iterator->next();
$empty = isEmpty($iterator); // ?
Should $iterator = new ArrayIterator([1, 2]);
$iterator->next();
isEmpty($iterator);
$value = $iterator->current(); // ?
Side note: We could simply remove the special handling of an empty batch and the |
|
Makes sense. The iterable will be modified. |
No description provided.