Esempio n. 1
0
 public function testTimes()
 {
     $fib = function ($n) {
         // http://stackoverflow.com/a/27190248/49146
         return (int) round(pow((sqrt(5) + 1) / 2, $n) / sqrt(5));
     };
     $expected = [0, 1, 1, 2, 3, 5, 8, 13];
     $this->assertSame($expected, Underscore::times(8, $fib)->toArray());
 }
function _times($n, $iterator, $context = NULL)
{
    return Underscore::times($n, $iterator, $context);
}
Esempio n. 3
0
 /**
  * @tags utilities
  */
 public function testTimes()
 {
     $fn = function () {
         static $num = 0;
         return ++$num;
     };
     $this->array(_::times(3, $fn))->isEqualTo([1, 2, 3]);
 }