From 04a05b4c02e59d1404d2316d75e49e6e8d9d12d0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 10 May 2012 01:48:20 -0400 Subject: [PATCH] Cleanup _.max and _.min unit tests. Former-commit-id: 5bfdd6d441f20879f3352f260b9b08e714c7b836 --- test/test.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/test/test.js b/test/test.js index 35e4d756e..f879e5867 100644 --- a/test/test.js +++ b/test/test.js @@ -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); + }); }); - }); + }()); /*--------------------------------------------------------------------------*/