Update _.random docs and add unit tests.

Former-commit-id: d4a033bf83ad5fce7bb3b09467305730a89adc01
This commit is contained in:
John-David Dalton
2012-12-28 20:22:04 -06:00
parent 87f880ca52
commit 716a5b9b5a
3 changed files with 22 additions and 4 deletions

View File

@@ -1396,6 +1396,24 @@
}
notEqual(actual, 5);
});
test('supports large integer values', function() {
var array = Array(1000),
min = Math.pow(2, 31),
max = Math.pow(2, 62);
ok(_.every(array, function() {
return _.random(min, max) >= min;
}));
ok(_.some(array, function() {
return _.random(Number.MAX_VALUE) > 0;
}));
});
test('should coerce arguments to numbers', function() {
strictEqual(_.random('1', '1'), 1);
});
}());
/*--------------------------------------------------------------------------*/