Exemplo n.º 1
0
 public function testRest()
 {
     $numbers = array(1, 2, 3, 4);
     // from js
     $this->assertEquals(array(2, 3, 4), __::rest($numbers), 'working rest()');
     $this->assertEquals(array(1, 2, 3, 4), __::rest($numbers, 0), 'working rest(0)');
     $this->assertEquals(array(3, 4), __::rest($numbers, 2), 'rest can take an index');
     $result = __::map(array(array(1, 2, 3), array(1, 2, 3)), function ($vals) {
         return __::rest($vals);
     });
     $this->assertEquals('2,3,2,3', join(',', __::flatten($result)), 'works well with __::map');
     // extra
     $this->assertEquals(array('b', 'c'), __::tail(array('a', 'b', 'c')));
     // docs
     $this->assertEquals(array(4, 3, 2, 1), __::rest(array(5, 4, 3, 2, 1)));
 }