mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Add sparse array tests for _.remove.
Former-commit-id: 0c21484ae459fbb1554c73348a566703523ff297
This commit is contained in:
21
test/test.js
21
test/test.js
@@ -2811,9 +2811,6 @@
|
|||||||
_.pull(array, 1);
|
_.pull(array, 1);
|
||||||
equal(0 in array, false);
|
equal(0 in array, false);
|
||||||
equal(2 in array, false);
|
equal(2 in array, false);
|
||||||
|
|
||||||
_.pull(array, undefined);
|
|
||||||
deepEqual(array, [3]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should treat holes as `undefined`', function() {
|
test('should treat holes as `undefined`', function() {
|
||||||
@@ -3024,6 +3021,24 @@
|
|||||||
|
|
||||||
deepEqual(actual, [1, 2]);
|
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]);
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user