Cleanup _.max and _.min unit tests.

Former-commit-id: 5bfdd6d441f20879f3352f260b9b08e714c7b836
This commit is contained in:
John-David Dalton
2012-05-10 01:48:20 -04:00
parent 90989a816d
commit 04a05b4c02

View File

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