Skip to content

Commit

Permalink
test: add negative limit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fuwasegu committed Sep 14, 2023
1 parent bc8df43 commit 601eb3b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Support/SupportLazyCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,23 @@ public function testUniqueDoubleEnumeration()

$this->assertSame([1, 2], $data->all());
}

public function testTakeWithNegativeLimit()
{
$data = LazyCollection::times(10);

$this->assertSame([
7 => 8,
8 => 9,
9 => 10,
], $data->take(-3)->all());

$this->assertSame([
7 => 8,
8 => 9,
9 => 10,
], $data->take(-5)->take(-3)->all());

$this->assertSame($data->take(10)->all(), $data->take(-10)->all());
}
}

0 comments on commit 601eb3b

Please sign in to comment.