From 381cd535519278e3001fc41a40584b7727fe0ec1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 13 Aug 2013 23:42:29 -0700 Subject: [PATCH] Add sparse array tests for `_.remove`. Former-commit-id: 0c21484ae459fbb1554c73348a566703523ff297 --- test/test.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index 699f0509e..60fc57bb2 100644 --- a/test/test.js +++ b/test/test.js @@ -2811,9 +2811,6 @@ _.pull(array, 1); equal(0 in array, false); equal(2 in array, false); - - _.pull(array, undefined); - deepEqual(array, [3]); }); test('should treat holes as `undefined`', function() { @@ -3024,6 +3021,24 @@ deepEqual(actual, [1, 2]); }); + + test('should preserve holes in arrays', function() { + var array = [1, 2, 3, 4]; + delete array[1]; + delete array[3]; + + _.remove(array, function(value) { return value === 1; }); + equal(0 in array, false); + equal(2 in array, false); + }); + + test('should treat holes as `undefined`', function() { + var array = [1, 2, 3]; + delete array[1]; + + _.remove(array, function(value) { return value == null; }); + deepEqual(array, [1, 3]); + }); }()); /*--------------------------------------------------------------------------*/