Add _.flatten test to ensure consistent behavior with sparse arrays.

Former-commit-id: 5505f4d0542596e4c6469aa038fa1bfecaa79800
This commit is contained in:
John-David Dalton
2012-05-23 14:28:51 -04:00
parent afb041b23c
commit 3670bce918

View File

@@ -174,6 +174,27 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.flatten');
(function() {
test('should treat sparse arrays as dense', function() {
var array = [[1, 2, 3], Array(3)],
expected = [1, 2, 3],
actual1 = _.flatten(array),
actual2 = _.flatten(array, true);
expected.push(undefined, undefined, undefined);
deepEqual(actual1, expected);
ok('4' in actual1);
deepEqual(actual2, expected);
ok('4' in actual2);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.forEach');
(function() {