Ensure _.merge produces dense arrays and revert accepting arrays of arguments for _.compose, _.defaults, _.extend, and _.merge.

Former-commit-id: a02772f8be04e187cbbfeb324cd4fb4318098162
This commit is contained in:
John-David Dalton
2013-01-15 01:32:21 -08:00
parent 0a53f762fe
commit 16a204335e
7 changed files with 194 additions and 213 deletions

View File

@@ -395,23 +395,6 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.compose');
(function() {
test('should accept arrays of functions', function() {
var composed = _.compose([
function(c) { return c + 'd'; },
function(b) { return b + 'c'; }
], [
function(a) { return a + 'b'; }
]);
equal(composed('a'), 'abcd');
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.contains');
(function() {
@@ -548,11 +531,6 @@
Foo.prototype = { 'a': 1 };
deepEqual(func({}, new Foo), {});
});
test('lodash.' + methodName + ' should accept arrays of source objects', function() {
var actual = func({}, [{ 'a': 1 }, { 'b': 2 }], [{ 'c': 3 }]);
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 });
});
});
/*--------------------------------------------------------------------------*/
@@ -1406,9 +1384,24 @@
});
test('should not assign `undefined` values', function() {
var a
var actual = _.merge({ 'a': 1 }, { 'a': undefined });
strictEqual(actual.a, 1);
});
test('should treat sparse arrays as dense', function() {
var array = Array(3);
array[0] = 1;
array[2] = 3;
var actual = _.merge([], array),
expected = array.slice();
expected[1] = undefined;
ok(1 in actual);
deepEqual(actual, expected);
});
}(1, 2, 3));
/*--------------------------------------------------------------------------*/