mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
Add _.random.
Former-commit-id: cf720b9187b0b54b43773a9f5f02fb475d786bfa
This commit is contained in:
21
test/test.js
21
test/test.js
@@ -1161,6 +1161,27 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.random');
|
||||
|
||||
(function() {
|
||||
test('should work like `Math.random` if no arguments are passed', function() {
|
||||
var actual = _.random();
|
||||
ok(actual >= 0 && actual < 1);
|
||||
});
|
||||
|
||||
test('supports not passing a `max` argument', function() {
|
||||
var actual = _.random(5),
|
||||
start = new Date;
|
||||
|
||||
while ((new Date - start) < 50 && actual == 5) {
|
||||
actual = _.random(5);
|
||||
}
|
||||
ok(actual != 5);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.range');
|
||||
|
||||
(function() {
|
||||
|
||||
Reference in New Issue
Block a user