}
if (is_int($values) || is_float($values)) {
- return mt_rand(0, $values);
+ return ($values < 0) ? mt_rand($values, 0) : mt_rand(0, $values);
}
if ($values instanceof Traversable) {
5.9,
range(0, 5, 1),
),
+ array( // negative
+ -2,
+ array(0, -1, -2),
+ ),
);
}
}
}
+ public function testRandomFunctionReturnsAsIs()
+ {
+ $this->assertSame('', twig_random(''));
+
+ $instance = new stdClass();
+ $this->assertSame($instance, twig_random($instance));
+ }
+
/**
* @expectedException Twig_Error_Runtime
*/