From 7053e9113f59247cb2df7d247ef84f1811871192 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 4 Jun 2012 16:18:23 -0400 Subject: [PATCH] Add unit test for `_.sortedIndex` to ensure it supports arrays with high `length` values. Former-commit-id: 8956495dfa40c75dcb3c0585e78913607bf92e99 --- test/test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test.js b/test/test.js index 8962a574c..b62b26227 100644 --- a/test/test.js +++ b/test/test.js @@ -582,6 +582,17 @@ equal(actual, 0); }); + + test('supports arrays with lengths larger than `Math.pow(2, 31) - 1`', function() { + var length = Math.pow(2, 32) - 1, + index = length - 1, + array = Array(length), + steps = 0; + + array[index] = index; + _.sortedIndex(array, index, function() { steps++; }); + equal(steps, 33); + }); }()); /*--------------------------------------------------------------------------*/