mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Ensure _.times doesn't error when passed negative numbers.
Former-commit-id: 5d694743fbda0f477250fe3c90cf29168834ac6f
This commit is contained in:
@@ -911,6 +911,7 @@
|
||||
|
||||
strictEqual(lodash.result(), null, '_.result should return `null` for falsey `object` arguments: ' + basename);
|
||||
strictEqual(lodash.some([false, true, false]), true, '_.some: ' + basename);
|
||||
deepEqual(lodash.times(null, function() {}), [null], '_.times should not coerce `n` to a number: ' + basename);
|
||||
equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename);
|
||||
equal('imports' in lodash.templateSettings, false, '_.templateSettings should not have an "imports" property: ' + basename);
|
||||
strictEqual(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename);
|
||||
|
||||
14
test/test.js
14
test/test.js
@@ -2603,6 +2603,20 @@
|
||||
test('should return an array of the results of each `callback` execution', function() {
|
||||
deepEqual(_.times(3, function(n) { return n * 2; }), [0, 2, 4]);
|
||||
});
|
||||
|
||||
test('should coerce `n` to a number', function() {
|
||||
deepEqual(_.times(null), []);
|
||||
});
|
||||
|
||||
test('should not error on negative `n` values', function() {
|
||||
var pass = true;
|
||||
try {
|
||||
_.times(-1);
|
||||
} catch(e) {
|
||||
pass = false;
|
||||
}
|
||||
ok(pass);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user