lodash: Ensure max and min do not error when computing the result of massive arrays. [cederberg, jddalton, jeeyoungk]

Former-commit-id: af982790c3bb62777523f972a95b7115fb645180
This commit is contained in:
John-David Dalton
2012-05-06 19:38:15 -04:00
parent d26fc7154c
commit 52cf17b24a
4 changed files with 114 additions and 92 deletions

View File

@@ -176,6 +176,27 @@
/*--------------------------------------------------------------------------*/
_.each(['max', 'min'], function(methodName) {
QUnit.module('lodash.' + methodName);
test('does not error when computing the ' + methodName + ' value of massive arrays', function() {
var actual,
array = [],
i = -1;
while (++i <= 1e6) {
array[i] = i;
}
try {
actual = _[methodName](array);
} catch(e) { }
equal(actual, methodName == 'max' ? 1e6 : 0);
});
});
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.partial');
(function() {