From 1f0e92a7526d8cbdb47cee84bfc9934d9e11bd1b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 12 Aug 2013 22:17:49 -0700 Subject: [PATCH] Add spare array test for `_.pull`. Former-commit-id: 38d677a4f2693db0591a6b43fe5a66a7dae39883 --- test/test.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index 487307fdb..699f0509e 100644 --- a/test/test.js +++ b/test/test.js @@ -2801,7 +2801,28 @@ deepEqual(array, [2]); ok(actual === array); - }) + }); + + test('should preserve holes in arrays', function() { + var array = [1, 2, 3, 4]; + delete array[1]; + delete array[3]; + + _.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() { + var array = [1, 2, 3]; + delete array[1]; + + _.pull(array, undefined); + deepEqual(array, [1, 3]); + }); }()); /*--------------------------------------------------------------------------*/