mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Add support for floating point numbers to _.random. [closes #263]
Former-commit-id: ef356bb180b163fc936ef69ac2ef33186983eaa7
This commit is contained in:
@@ -2306,6 +2306,15 @@
|
||||
test('should coerce arguments to numbers', function() {
|
||||
strictEqual(_.random('1', '1'), 1);
|
||||
});
|
||||
|
||||
test('should support floats', function() {
|
||||
var min = 1.5,
|
||||
max = 1.6,
|
||||
actual = _.random(min, max);
|
||||
|
||||
ok(actual % 1);
|
||||
ok(actual >= min && actual <= max);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user