Skip to content

Commit

Permalink
Do not calculate range twice
Browse files Browse the repository at this point in the history
  • Loading branch information
ravage84 committed Sep 6, 2018
1 parent 984d070 commit d047b7a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/TestCase/Collection/CollectionTest.php
Expand Up @@ -2226,11 +2226,13 @@ public function testLastNtWithOddData($data)
*/
public function testLastNtWithCountable()
{
$collection = new Collection(new CountableIterator(range(0, 5)));
$rangeZeroToFive = range(0, 5);

$collection = new Collection(new CountableIterator($rangeZeroToFive));
$result = $collection->takeLast(2)->toList();
$this->assertEquals([4, 5], $result);

$collection = new Collection(new CountableIterator(range(0, 5)));
$collection = new Collection(new CountableIterator($rangeZeroToFive));
$result = $collection->takeLast(1)->toList();
$this->assertEquals([5], $result);
}
Expand Down

0 comments on commit d047b7a

Please sign in to comment.