mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Fix spread test fail.
This commit is contained in:
@@ -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]);
|
||||
|
||||
14
test/test.js
14
test/test.js
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user