Ensure _.times doesn't error when passed negative numbers.

Former-commit-id: 5d694743fbda0f477250fe3c90cf29168834ac6f
This commit is contained in:
John-David Dalton
2013-03-07 09:05:27 -08:00
parent 952afa05ce
commit 11ba02067e
4 changed files with 29 additions and 1 deletions

View File

@@ -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);
});
}());
/*--------------------------------------------------------------------------*/