Fix spread test fail.

This commit is contained in:
John-David Dalton
2015-11-28 23:33:47 -06:00
parent 3874b5bf84
commit 0a55eff5d5
2 changed files with 14 additions and 3 deletions

View File

@@ -383,7 +383,8 @@
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
var length = args ? args.length : 0;
switch (length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);

View File

@@ -17716,10 +17716,20 @@
assert.strictEqual(spread([4, 2]), 6);
});
QUnit.test('should throw a TypeError when receiving a non-array `array` argument', function(assert) {
QUnit.test('should accept a falsey `array` argument', function(assert) {
assert.expect(1);
assert.raises(function() { _.spread(4, 2); }, TypeError);
var alwaysTrue = lodashStable.constant(true),
spread = _.spread(alwaysTrue),
expected = lodashStable.map(falsey, alwaysTrue);
var actual = lodashStable.map(falsey, function(array, index) {
try {
return index ? spread(array) : spread();
} catch (e) {}
});
assert.deepEqual(actual, expected);
});
QUnit.test('should provide the correct `func` arguments', function(assert) {