Skip to content

Commit b10aa05

Browse files
committed
test: first/last and alias
1 parent ebd0ffc commit b10aa05

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/ArrayTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ public function test_first_last()
1515

1616
$array = ['x' => ['first'], 'z' => 'last'];
1717

18-
$this->assertSame($array['x'], _::_($array)->first(), 'first');
19-
$this->assertSame($array['z'], _::_($array)->last(), 'last');
18+
$this->assertSame($array['x'], _::_($array)->head(), 'first');
19+
$this->assertSame($array['z'], _::_($array)->tail(), 'last');
20+
21+
$array = range(1, 5);
22+
23+
$this->assertSame([1, 2, 3], _::_($array)->take(3), 'first 3');
24+
$this->assertSame([1, 2, 3, 4, 5], _::_($array)->first(6), 'first 6 (n + 1)');
25+
$this->assertSame([2 => 3, 3 => 4, 4 => 5], _::_($array)->drop(3), 'last 3');
26+
$this->assertSame([1, 2, 3, 4, 5], _::_($array)->last(6), 'last 6 (n + 1)');
2027
}
2128

2229
public function test_compact()

0 commit comments

Comments
 (0)