From 36f5ddc543c6dfa26898a52c96661aa45bc7263f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 24 Aug 2014 21:31:07 -0700 Subject: [PATCH] Add test for hot methods. --- test/test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/test.js b/test/test.js index 25799a124..b348da1cc 100644 --- a/test/test.js +++ b/test/test.js @@ -3,6 +3,9 @@ /** Used as a safe reference for `undefined` in pre ES5 environments */ var undefined; + /** Used to detect when a function becomes hot */ + var HOT_COUNT = 150; + /** Used as the size to cover large array optimizations */ var LARGE_ARRAY_SIZE = 200; @@ -2452,6 +2455,28 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('curry methods'); + + _.each(['curry', 'curryRight'], function(methodName) { + var func = _[methodName]; + + function fn(a, b, c, d) { + return slice.call(arguments); + } + + test('`_.' + methodName + '` should work when hot', 1, function() { + var curried = func(fn); + + var actual = _.last(_.times(HOT_COUNT, function() { + return curried(1)(2)(3)(4); + })); + + deepEqual(actual, [1, 2, 3, 4]); + }); + }); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.debounce'); (function() {