From 601eb3b3ed239cd7ff5396c70b8f6e07f3bca6a5 Mon Sep 17 00:00:00 2001 From: fuwasegu Date: Thu, 14 Sep 2023 16:56:46 +0900 Subject: [PATCH] test: add negative limit test --- tests/Support/SupportLazyCollectionTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Support/SupportLazyCollectionTest.php b/tests/Support/SupportLazyCollectionTest.php index 1db8c2ead02d..0a23c9f463ba 100644 --- a/tests/Support/SupportLazyCollectionTest.php +++ b/tests/Support/SupportLazyCollectionTest.php @@ -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()); + } }