From 2357704540130fb394af3c01ebd249ed658725ca Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 10 May 2016 16:16:23 -0700 Subject: [PATCH] Add `_.mockArray`, `_.mockFalse`, `_.mockObject`, `_.mockString`, and `_.mockTrue`. --- lodash.js | 145 +++++++++++++--- test/test.js | 472 ++++++++++++++++++++++++++------------------------- 2 files changed, 362 insertions(+), 255 deletions(-) diff --git a/lodash.js b/lodash.js index 45ea627d5..8e74fe0dd 100644 --- a/lodash.js +++ b/lodash.js @@ -1420,19 +1420,21 @@ * `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, * `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, - * `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, - * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, - * `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, - * `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, - * `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`, - * `noConflict`, `noop`, `now`, `nth`, `pad`, `padEnd`, `padStart`, `parseInt`, - * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`, - * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, - * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, - * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toFinite`, - * `toInteger`, `toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`, - * `toString`, `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, - * `uniqueId`, `upperCase`, `upperFirst`, `value`, and `words` + * `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, + * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, + * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, + * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, + * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, + * `min`, `minBy`, `mockArray`, `mockFalse`, `mockObject`, `mockString`, + * `mockTrue`, multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, `padEnd`, + * `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, + * `result`, `round`, `runInContext`, `sample`, `shift`, `size`, `snakeCase`, + * `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, + * `startCase`, `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, + * `toFinite`, `toInteger`, `toJSON`, `toLength`, `toLower`, `toNumber`, + * `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`, `trimStart`, + * `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`, `value`, + * and `words` * * @name _ * @constructor @@ -5420,9 +5422,7 @@ // Fallback for IE < 11. if (!getOwnPropertySymbols) { - getSymbols = function() { - return []; - }; + getSymbols = mockArray; } /** @@ -14644,10 +14644,12 @@ * @returns {Function} Returns the new constant function. * @example * - * var object = { 'user': 'fred' }; - * var getter = _.constant(object); + * var objects = _.times(2, _.constant({ 'a': 1 })); * - * getter() === object; + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] + * + * console.log(objects[0] === objects[1]); * // => true */ function constant(value) { @@ -14716,7 +14718,7 @@ * * var object = { 'user': 'fred' }; * - * _.identity(object) === object; + * console.log(_.identity(object) === object); * // => true */ function identity(value) { @@ -14956,6 +14958,95 @@ return object; } + /** + * A method that returns a new empty array. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. + * @example + * + * var arrays = _.times(2, _.mockArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false + */ + function mockArray() { + return []; + } + + /** + * A method that returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2 _.mockFalse); + * // => [false, false] + */ + var mockFalse = constant(false); + + /** + * A method that returns a new empty object. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Object} Returns the new empty object. + * @example + * + * var objects = _.times(2, _.mockObject); + * + * console.log(objects); + * // => [{}, {}] + * + * console.log(objects[0] === objects[1]); + * // => false + */ + function mockObject() { + return {}; + } + + /** + * A method that returns an empty string. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {string} Returns the empty string. + * @example + * + * _.times(2, _.mockString); + * // => ['', ''] + */ + var mockString = constant(''); + + /** + * A method that returns `true`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `true`. + * @example + * + * _.times(2, _.mockTrue); + * // => [true, true] + */ + var mockTrue = constant(true); + /** * Reverts the `_` variable to its previous value and returns a reference to * the `lodash` function. @@ -14977,8 +15068,7 @@ } /** - * A no-operation function that returns `undefined` regardless of the - * arguments it receives. + * A method that returns `undefined`. * * @static * @memberOf _ @@ -14986,10 +15076,8 @@ * @category Util * @example * - * var object = { 'user': 'fred' }; - * - * _.noop(object) === undefined; - * // => true + * _.times(2, _.noop); + * // => [undefined, undefined] */ function noop() { // No operation performed. @@ -15919,6 +16007,11 @@ lodash.meanBy = meanBy; lodash.min = min; lodash.minBy = minBy; + lodash.mockArray = mockArray; + lodash.mockFalse = mockFalse; + lodash.mockObject = mockObject; + lodash.mockTrue = mockTrue; + lodash.mockString = mockString; lodash.multiply = multiply; lodash.nth = nth; lodash.noConflict = noConflict; diff --git a/test/test.js b/test/test.js index 1d9055590..94991a825 100644 --- a/test/test.js +++ b/test/test.js @@ -83,26 +83,26 @@ isEven = function(n) { return n % 2 == 0; }, square = function(n) { return n * n; }; - /** Constant functions. */ - var alwaysA = function() { return 'a'; }, - alwaysB = function() { return 'b'; }, - alwaysC = function() { return 'c'; }; + /** Mock functions. */ + var mockA = function() { return 'a'; }, + mockB = function() { return 'b'; }, + mockC = function() { return 'c'; }; - var alwaysTrue = function() { return true; }, - alwaysFalse = function() { return false; }; + var mockTrue = function() { return true; }, + mockFalse = function() { return false; }; - var alwaysNaN = function() { return NaN; }, - alwaysNull = function() { return null; }; + var mockNaN = function() { return NaN; }, + mockNull = function() { return null; }; - var alwaysZero = function() { return 0; }, - alwaysOne = function() { return 1; }, - alwaysTwo = function() { return 2; }, - alwaysThree = function() { return 3; }, - alwaysFour = function() { return 4; }; + var mockZero = function() { return 0; }, + mockOne = function() { return 1; }, + mockTwo = function() { return 2; }, + mockThree = function() { return 3; }, + mockFour = function() { return 4; }; - var alwaysEmptyArray = function() { return []; }, - alwaysEmptyObject = function() { return {}; }, - alwaysEmptyString = function() { return ''; }; + var mockArray = function() { return []; }, + mockObject = function() { return {}; }, + mockString = function() { return ''; }; /** List of latin-1 supplementary letters to basic latin letters. */ var burredLetters = [ @@ -905,7 +905,7 @@ if (func) { var values = [[0], ['0'], ['1'], [3, 4], [MAX_SAFE_INTEGER - 1]], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(args) { return func.apply(undefined, args); @@ -923,7 +923,7 @@ if (func) { var values = [['1abc'], ['07'], ['0001'], [-1], [3, 3], [1.1], [MAX_SAFE_INTEGER]], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(args) { return func.apply(undefined, args); @@ -1062,7 +1062,7 @@ (function() { var values = empties.concat(true, 1, 'a'), - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); QUnit.test('should create a new instance when called without the `new` operator', function(assert) { assert.expect(1); @@ -1335,7 +1335,7 @@ }; defineProperty(object, 'a', lodashStable.assign({}, descriptor, { - 'get': alwaysOne + 'get': mockOne })); defineProperty(object, 'b', lodashStable.assign({}, descriptor, { @@ -1343,7 +1343,7 @@ })); defineProperty(object, 'c', lodashStable.assign({}, descriptor, { - 'get': alwaysNaN + 'get': mockNaN })); defineProperty(object, 'constructor', lodashStable.assign({}, descriptor, { @@ -1453,7 +1453,7 @@ result[value] = 1; }, []); - var expected = lodashStable.map(values, alwaysOne), + var expected = lodashStable.map(values, mockOne), actual = _.at(array, values); assert.deepEqual(actual, expected); @@ -1606,7 +1606,7 @@ QUnit.test('should return the caught error', function(assert) { assert.expect(1); - var expected = lodashStable.map(errors, alwaysTrue); + var expected = lodashStable.map(errors, mockTrue); var actual = lodashStable.map(errors, function(error) { return _.attempt(function() { throw error; }) === error; @@ -1633,7 +1633,7 @@ assert.expect(1); if (realm.errors) { - var expected = lodashStable.map(realm.errors, alwaysTrue); + var expected = lodashStable.map(realm.errors, mockTrue); var actual = lodashStable.map(realm.errors, function(error) { return _.attempt(function() { throw error; }) === error; @@ -1938,7 +1938,7 @@ if (typeof createCtor == 'function') { var bound = _.bind(createCtor()), count = 8, - expected = lodashStable.times(count, alwaysTrue); + expected = lodashStable.times(count, mockTrue); var actual = lodashStable.times(count, function(index) { try { @@ -2176,7 +2176,7 @@ return func(string) === expected; }); - assert.deepEqual(actual, lodashStable.map(strings, alwaysTrue)); + assert.deepEqual(actual, lodashStable.map(strings, mockTrue)); }); QUnit.test('`_.' + methodName + '` should handle double-converting strings', function(assert) { @@ -2187,7 +2187,7 @@ return func(func(string)) === expected; }); - assert.deepEqual(actual, lodashStable.map(strings, alwaysTrue)); + assert.deepEqual(actual, lodashStable.map(strings, mockTrue)); }); QUnit.test('`_.' + methodName + '` should deburr letters', function(assert) { @@ -2205,7 +2205,7 @@ return func(burred) === letter; }); - assert.deepEqual(actual, lodashStable.map(burredLetters, alwaysTrue)); + assert.deepEqual(actual, lodashStable.map(burredLetters, mockTrue)); }); QUnit.test('`_.' + methodName + '` should remove contraction apostrophes', function(assert) { @@ -2502,7 +2502,7 @@ assert.expect(1); var values = lodashStable.reject(falsey, lodashStable.isUndefined).concat(-1, -Infinity), - expected = lodashStable.map(values, alwaysEmptyArray); + expected = lodashStable.map(values, mockArray); var actual = lodashStable.map(values, function(n) { return _.chunk(array, n); @@ -2798,7 +2798,7 @@ return object; }); - var expected = lodashStable.map(values, alwaysTrue); + var expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { return func(value).a === 1; @@ -2949,7 +2949,7 @@ } }, []); - var expected = lodashStable.map(objects, alwaysTrue); + var expected = lodashStable.map(objects, mockTrue); var actual = lodashStable.map(objects, function(object) { var Ctor = object.constructor, @@ -3240,9 +3240,9 @@ assert.expect(3); var cond = _.cond([ - [lodashStable.matches({ 'a': 1 }), alwaysA], - [lodashStable.matchesProperty('b', 1), alwaysB], - [lodashStable.property('c'), alwaysC] + [lodashStable.matches({ 'a': 1 }), mockA], + [lodashStable.matchesProperty('b', 1), mockB], + [lodashStable.property('c'), mockC] ]); assert.strictEqual(cond({ 'a': 1, 'b': 2, 'c': 3 }), 'a'); @@ -3272,9 +3272,9 @@ assert.expect(3); var cond = _.cond([ - [{ 'a': 1 }, alwaysA], - [['b', 1], alwaysB], - ['c', alwaysC] + [{ 'a': 1 }, mockA], + [['b', 1], mockB], + ['c', mockC] ]); assert.strictEqual(cond({ 'a': 1, 'b': 2, 'c': 3 }), 'a'); @@ -3285,7 +3285,7 @@ QUnit.test('should return `undefined` when no condition is met', function(assert) { assert.expect(1); - var cond = _.cond([[alwaysFalse, alwaysA]]); + var cond = _.cond([[mockFalse, mockA]]); assert.strictEqual(cond({ 'a': 1 }), undefined); }); @@ -3293,7 +3293,7 @@ assert.expect(2); lodashStable.each([false, true], function(value) { - assert.raises(function() { _.cond([[alwaysTrue, value]])(); }, TypeError); + assert.raises(function() { _.cond([[mockTrue, value]])(); }, TypeError); }); }); @@ -3418,7 +3418,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var conforms = _.conforms({ 'a': function(value) { return value > 1; } @@ -3437,7 +3437,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysTrue), + expected = lodashStable.map(values, mockTrue), conforms = _.conforms({}); var actual = lodashStable.map(values, function(value, index) { @@ -3453,7 +3453,7 @@ assert.expect(1); var object = { 'a': 1 }, - expected = lodashStable.map(empties, alwaysTrue); + expected = lodashStable.map(empties, mockTrue); var actual = lodashStable.map(empties, function(value) { var conforms = _.conforms(value); @@ -3491,7 +3491,7 @@ var object = { 'a': 1 }, values = Array(2).concat(empties, true, 1, 'a'), constant = _.constant(object), - expected = lodashStable.map(values, function() { return true; }); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value, index) { if (index == 0) { @@ -3510,7 +3510,7 @@ QUnit.test('should work with falsey values', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, function() { return true; }); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(value, index) { var constant = index ? _.constant(value) : _.constant(), @@ -3685,7 +3685,7 @@ QUnit.test('should accept a falsey `prototype` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyObject); + var expected = lodashStable.map(falsey, mockObject); var actual = lodashStable.map(falsey, function(prototype, index) { return index ? _.create(prototype) : _.create(); @@ -3697,7 +3697,7 @@ QUnit.test('should ignore primitive `prototype` arguments and use an empty object instead', function(assert) { assert.expect(1); - var expected = lodashStable.map(primitives, alwaysTrue); + var expected = lodashStable.map(primitives, mockTrue); var actual = lodashStable.map(primitives, function(value, index) { return lodashStable.isPlainObject(index ? _.create(value) : _.create()); @@ -3710,7 +3710,7 @@ assert.expect(1); var array = [{ 'a': 1 }, { 'a': 1 }, { 'a': 1 }], - expected = lodashStable.map(array, alwaysTrue), + expected = lodashStable.map(array, mockTrue), objects = lodashStable.map(array, _.create); var actual = lodashStable.map(objects, function(object) { @@ -3756,7 +3756,7 @@ assert.expect(2); var values = ['0', 0.6, 'xyz'], - expected = lodashStable.map(values, alwaysEmptyArray); + expected = lodashStable.map(values, mockArray); var actual = lodashStable.map(values, function(arity) { return _.curry(fn, arity)(); @@ -3914,7 +3914,7 @@ assert.expect(2); var values = ['0', 0.6, 'xyz'], - expected = lodashStable.map(values, alwaysEmptyArray); + expected = lodashStable.map(values, mockArray); var actual = lodashStable.map(values, function(arity) { return _.curryRight(fn, arity)(); @@ -4800,7 +4800,7 @@ assert.deepEqual(actual, [[], []]); - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysOne); + var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, mockOne); actual = lodashStable.map(func([-0, 1], largeArray), lodashStable.toString); assert.deepEqual(actual, ['0']); }); @@ -4808,7 +4808,7 @@ QUnit.test('`_.' + methodName + '` should work with large arrays of `NaN`', function(assert) { assert.expect(1); - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysNaN); + var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, mockNaN); assert.deepEqual(func([1, NaN, 3], largeArray), [1, 3]); }); @@ -4879,7 +4879,7 @@ assert.expect(1); var array = [-0, 1], - largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysOne), + largeArray = lodashStable.times(LARGE_ARRAY_SIZE, mockOne), others = [[1], largeArray], expected = lodashStable.map(others, lodashStable.constant(['-0'])); @@ -5285,7 +5285,7 @@ QUnit.test('should treat falsey `position` values, except `undefined`, as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(position) { return _.endsWith(string, position === undefined ? 'c' : '', position); @@ -5405,7 +5405,7 @@ assert.expect(1); var values = [, null, undefined, ''], - expected = lodashStable.map(values, alwaysEmptyString); + expected = lodashStable.map(values, mockString); var actual = lodashStable.map(values, function(value, index) { return index ? _.escapeRegExp(value) : _.escapeRegExp(); @@ -5429,7 +5429,7 @@ QUnit.test('should return `true` for empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, alwaysTrue); + var expected = lodashStable.map(empties, mockTrue); var actual = lodashStable.map(empties, function(value) { try { @@ -5463,7 +5463,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value, index) { var array = [0]; @@ -5472,7 +5472,7 @@ assert.deepEqual(actual, expected); - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); actual = lodashStable.map(values, function(value, index) { var array = [1]; return index ? _.every(array, value) : _.every(array); @@ -5720,7 +5720,7 @@ object = { '1': 'foo', '8': 'bar', '50': 'baz' }; lodashStable.times(1000, function(assert) { - _.filter([], alwaysTrue); + _.filter([], mockTrue); }); _.filter(object, function() { @@ -6035,7 +6035,7 @@ QUnit.test('`_.' + methodName + '` should accept a falsey `collection` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyArray); + var expected = lodashStable.map(falsey, mockArray); var actual = lodashStable.map(falsey, function(collection, index) { try { @@ -6700,7 +6700,7 @@ }; var values = [-1, '1', 1.1, Object(1), MAX_SAFE_INTEGER + 1], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(length) { return isIteratedAsObject({ 'length': length }); @@ -6837,7 +6837,7 @@ var source = { 'a': 1 }, values = [null, undefined], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { var object = func(value, source); @@ -7073,7 +7073,7 @@ QUnit.test('should accept a falsey `array` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyObject); + var expected = lodashStable.map(falsey, mockObject); var actual = lodashStable.map(falsey, function(array, index) { try { @@ -7356,7 +7356,7 @@ var object = { '-0': 'a', '0': 'b' }, props = [-0, Object(-0), 0, Object(0)], - expected = lodashStable.map(props, alwaysTrue); + expected = lodashStable.map(props, mockTrue); var actual = lodashStable.map(props, function(key) { return func(object, key); @@ -7437,7 +7437,7 @@ delete string[0]; var values = [Array(3), args, string], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { return func(value, 0); @@ -7461,7 +7461,7 @@ assert.expect(2); var values = [null, undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); lodashStable.each(['constructor', ['constructor']], function(path) { var actual = lodashStable.map(values, function(value) { @@ -7476,7 +7476,7 @@ assert.expect(2); var values = [null, undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { var actual = lodashStable.map(values, function(value) { @@ -7491,7 +7491,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); lodashStable.each(['a.b', ['a', 'b']], function(path) { var actual = lodashStable.map(values, function(value, index) { @@ -7655,7 +7655,7 @@ QUnit.test('should work with ' + key + ' and treat falsey `fromIndex` values as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(fromIndex) { return _.includes(collection, values[0], fromIndex); @@ -7732,7 +7732,7 @@ QUnit.test('should return `false` for empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, alwaysFalse); + var expected = lodashStable.map(empties, mockFalse); var actual = lodashStable.map(empties, function(value) { try { @@ -7814,7 +7814,7 @@ assert.expect(1); var values = [-6, -8, -Infinity], - expected = lodashStable.map(values, alwaysZero); + expected = lodashStable.map(values, mockZero); var actual = lodashStable.map(values, function(fromIndex) { return func(array, resolve(1), fromIndex); @@ -7826,7 +7826,7 @@ QUnit.test('`_.' + methodName + '` should treat falsey `fromIndex` values as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysZero); + var expected = lodashStable.map(falsey, mockZero); var actual = lodashStable.map(falsey, function(fromIndex) { return func(array, resolve(1), fromIndex); @@ -7852,7 +7852,7 @@ QUnit.test('should accept a falsey `array` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyArray); + var expected = lodashStable.map(falsey, mockArray); var actual = lodashStable.map(falsey, function(array, index) { try { @@ -7973,7 +7973,7 @@ assert.expect(1); var actual = [_.inRange(0, '0', 1), _.inRange(0, '1'), _.inRange(0, 0, '1'), _.inRange(0, NaN, 1), _.inRange(-1, -1, NaN)], - expected = lodashStable.map(actual, alwaysTrue); + expected = lodashStable.map(actual, mockTrue); assert.deepEqual(actual, expected); }); @@ -8068,7 +8068,7 @@ QUnit.test('`_.' + methodName + '` should work with large arrays of `NaN`', function(assert) { assert.expect(1); - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysNaN); + var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, mockNaN); assert.deepEqual(func([1, NaN, 3], largeArray), [NaN]); }); @@ -8152,7 +8152,7 @@ assert.expect(1); var array = [-0], - largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysZero), + largeArray = lodashStable.times(LARGE_ARRAY_SIZE, mockZero), others = [[0], largeArray], expected = lodashStable.map(others, lodashStable.constant(['-0'])); @@ -8306,7 +8306,7 @@ QUnit.test('should preserve the sign of `0`', function(assert) { assert.expect(1); - var object = { '-0': alwaysA, '0': alwaysB }, + var object = { '-0': mockA, '0': mockB }, props = [-0, Object(-0), 0, Object(0)]; var actual = lodashStable.map(props, function(key) { @@ -8341,7 +8341,7 @@ assert.expect(1); if (!isNpm) { - var object = { 'a': alwaysOne }; + var object = { 'a': mockOne }; assert.strictEqual(_(object).invoke('a'), 1); } else { @@ -8353,7 +8353,7 @@ assert.expect(1); if (!isNpm) { - var object = { 'a': alwaysOne }; + var object = { 'a': mockOne }; assert.ok(_(object).chain().invoke('a') instanceof _); } else { @@ -8427,7 +8427,7 @@ QUnit.test('should not error on elements with missing properties', function(assert) { assert.expect(1); - var objects = lodashStable.map([null, undefined, alwaysOne], function(value) { + var objects = lodashStable.map([null, undefined, mockOne], function(value) { return { 'a': value }; }); @@ -8515,7 +8515,7 @@ QUnit.test('should return `false` for non `arguments` objects', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isArguments(value) : _.isArguments(); @@ -8564,7 +8564,7 @@ QUnit.test('should return `false` for non-arrays', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isArray(value) : _.isArray(); @@ -8618,7 +8618,7 @@ QUnit.test('should return `false` for non array buffers', function(assert) { assert.expect(13); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isArrayBuffer(value) : _.isArrayBuffer(); @@ -8663,7 +8663,7 @@ assert.expect(1); var values = [args, [1, 2, 3], { '0': 1, 'length': 1 }, 'a'], - expected = lodashStable.map(values, alwaysTrue), + expected = lodashStable.map(values, mockTrue), actual = lodashStable.map(values, _.isArrayLike); assert.deepEqual(actual, expected); @@ -8699,7 +8699,7 @@ if (realm.object) { var values = [realm.arguments, realm.array, realm.string], - expected = lodashStable.map(values, alwaysTrue), + expected = lodashStable.map(values, mockTrue), actual = lodashStable.map(values, _.isArrayLike); assert.deepEqual(actual, expected); @@ -8785,7 +8785,7 @@ QUnit.test('should return `false` for non-buffers', function(assert) { assert.expect(13); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isBuffer(value) : _.isBuffer(); @@ -8835,7 +8835,7 @@ QUnit.test('should return `false` for non-dates', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isDate(value) : _.isDate(); @@ -8896,7 +8896,7 @@ QUnit.test('should return `false` for non DOM elements', function(assert) { assert.expect(13); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isElement(value) : _.isElement(); @@ -8940,7 +8940,7 @@ QUnit.test('should return `true` for empty values', function(assert) { assert.expect(10); - var expected = lodashStable.map(empties, alwaysTrue), + var expected = lodashStable.map(empties, mockTrue), actual = lodashStable.map(empties, _.isEmpty); assert.deepEqual(actual, expected); @@ -9429,7 +9429,7 @@ var primitive, object = { 'toString': function() { return primitive; } }, values = [true, null, 1, 'a', undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value) { primitive = value; @@ -9899,11 +9899,11 @@ QUnit.test('should return a boolean value even when `customizer` does not', function(assert) { assert.expect(2); - var actual = _.isEqualWith('a', 'b', alwaysC); + var actual = _.isEqualWith('a', 'b', mockC); assert.strictEqual(actual, true); var values = _.without(falsey, undefined), - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); actual = []; lodashStable.each(values, function(value) { @@ -9983,7 +9983,7 @@ QUnit.test('should return `true` for error objects', function(assert) { assert.expect(1); - var expected = lodashStable.map(errors, alwaysTrue); + var expected = lodashStable.map(errors, mockTrue); var actual = lodashStable.map(errors, function(error) { return _.isError(error) === true; @@ -10001,7 +10001,7 @@ QUnit.test('should return `false` for non error objects', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isError(value) : _.isError(); @@ -10026,7 +10026,7 @@ assert.expect(1); if (realm.errors) { - var expected = lodashStable.map(realm.errors, alwaysTrue); + var expected = lodashStable.map(realm.errors, mockTrue); var actual = lodashStable.map(realm.errors, function(error) { return _.isError(error) === true; @@ -10051,7 +10051,7 @@ assert.expect(1); var values = [0, 1, 3.14, -1], - expected = lodashStable.map(values, alwaysTrue), + expected = lodashStable.map(values, mockTrue), actual = lodashStable.map(values, _.isFinite); assert.deepEqual(actual, expected); @@ -10061,7 +10061,7 @@ assert.expect(1); var values = [NaN, Infinity, -Infinity, Object(1)], - expected = lodashStable.map(values, alwaysFalse), + expected = lodashStable.map(values, mockFalse), actual = lodashStable.map(values, _.isFinite); assert.deepEqual(actual, expected); @@ -10071,7 +10071,7 @@ assert.expect(10); var values = [undefined, [], true, '', ' ', '2px'], - expected = lodashStable.map(values, alwaysFalse), + expected = lodashStable.map(values, mockFalse), actual = lodashStable.map(values, _.isFinite); assert.deepEqual(actual, expected); @@ -10091,7 +10091,7 @@ assert.expect(1); var values = ['2', '0', '08'], - expected = lodashStable.map(values, alwaysFalse), + expected = lodashStable.map(values, mockFalse), actual = lodashStable.map(values, _.isFinite); assert.deepEqual(actual, expected); @@ -10135,7 +10135,7 @@ QUnit.test('should return `false` for non-functions', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isFunction(value) : _.isFunction(); @@ -10202,7 +10202,7 @@ assert.expect(2); var values = [-1, 0, 1], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { return func(value); @@ -10216,7 +10216,7 @@ assert.expect(1); var values = [NaN, Infinity, -Infinity, Object(1), 3.14], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value) { return func(value); @@ -10259,7 +10259,7 @@ assert.expect(1); var values = [0, 3, MAX_SAFE_INTEGER], - expected = lodashStable.map(values, alwaysTrue), + expected = lodashStable.map(values, mockTrue), actual = lodashStable.map(values, _.isLength); assert.deepEqual(actual, expected); @@ -10269,7 +10269,7 @@ assert.expect(1); var values = [-1, '1', 1.1, MAX_SAFE_INTEGER + 1], - expected = lodashStable.map(values, alwaysFalse), + expected = lodashStable.map(values, mockFalse), actual = lodashStable.map(values, _.isLength); assert.deepEqual(actual, expected); @@ -10297,7 +10297,7 @@ QUnit.test('should return `false` for non-maps', function(assert) { assert.expect(14); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isMap(value) : _.isMap(); @@ -10324,7 +10324,7 @@ assert.expect(1); var values = [false, true], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value) { return _.isMap({ 'constructor': value }); @@ -10384,7 +10384,7 @@ var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], source = new Foo, - expected = lodashStable.map(objects, alwaysTrue); + expected = lodashStable.map(objects, mockTrue); var actual = lodashStable.map(objects, function(object) { return _.isMatch(object, source); @@ -10630,7 +10630,7 @@ assert.expect(1); var values = [null, undefined], - expected = lodashStable.map(values, alwaysFalse), + expected = lodashStable.map(values, mockFalse), source = { 'a': 1 }; var actual = lodashStable.map(values, function(value) { @@ -10646,7 +10646,7 @@ assert.expect(1); var values = [null, undefined], - expected = lodashStable.map(values, alwaysTrue), + expected = lodashStable.map(values, mockTrue), source = {}; var actual = lodashStable.map(values, function(value) { @@ -10662,7 +10662,7 @@ assert.expect(1); var object = { 'a': 1 }, - expected = lodashStable.map(empties, alwaysTrue); + expected = lodashStable.map(empties, mockTrue); var actual = lodashStable.map(empties, function(value) { return _.isMatch(object, value); @@ -10754,11 +10754,11 @@ assert.expect(2); var object = { 'a': 1 }, - actual = _.isMatchWith(object, { 'a': 1 }, alwaysA); + actual = _.isMatchWith(object, { 'a': 1 }, mockA); assert.strictEqual(actual, true); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); actual = []; lodashStable.each(falsey, function(value) { @@ -10916,7 +10916,7 @@ QUnit.test('should return `false` for non-native methods', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isNative(value) : _.isNative(); @@ -11167,7 +11167,7 @@ assert.expect(1); var values = falsey.concat(true, 1, 'a', symbol), - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value, index) { return index ? _.isObject(value) : _.isObject(); @@ -11241,7 +11241,7 @@ assert.expect(1); var values = falsey.concat(true, _, slice, 1, 'a', symbol), - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value, index) { return index ? _.isObjectLike(value) : _.isObjectLike(); @@ -11353,7 +11353,7 @@ QUnit.test('should return `false` for non-objects', function(assert) { assert.expect(4); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isPlainObject(value) : _.isPlainObject(); @@ -11395,7 +11395,7 @@ QUnit.test('should return `false` for non-regexes', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isRegExp(value) : _.isRegExp(); @@ -11449,7 +11449,7 @@ QUnit.test('should return `false` for non-sets', function(assert) { assert.expect(14); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isSet(value) : _.isSet(); @@ -11476,7 +11476,7 @@ assert.expect(1); var values = [false, true], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value) { return _.isSet({ 'constructor': value }); @@ -11571,7 +11571,7 @@ QUnit.test('should return `false` for non-symbols', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isSymbol(value) : _.isSymbol(); @@ -11629,7 +11629,7 @@ QUnit.test('should return `false` for non typed arrays', function(assert) { assert.expect(13); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isTypedArray(value) : _.isTypedArray(); @@ -11754,7 +11754,7 @@ QUnit.test('should return `false` for non weak maps', function(assert) { assert.expect(14); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isWeakMap(value) : _.isWeakMap(); @@ -11781,7 +11781,7 @@ assert.expect(1); var values = [false, true], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value) { return _.isWeakMap({ 'constructor': value }); @@ -11823,7 +11823,7 @@ QUnit.test('should return `false` for non weak sets', function(assert) { assert.expect(14); - var expected = lodashStable.map(falsey, alwaysFalse); + var expected = lodashStable.map(falsey, mockFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isWeakSet(value) : _.isWeakSet(); @@ -12090,7 +12090,7 @@ var fn = function() { return this instanceof Number; }, array = [fn, fn, fn], iteratees = lodashStable.map(array, _.iteratee), - expected = lodashStable.map(array, alwaysFalse); + expected = lodashStable.map(array, mockFalse); var actual = lodashStable.map(iteratees, function(iteratee) { return iteratee(); @@ -13162,7 +13162,7 @@ assert.expect(1); var values = [-6, -8, -Infinity], - expected = lodashStable.map(values, alwaysZero); + expected = lodashStable.map(values, mockZero); var actual = lodashStable.map(values, function(fromIndex) { return func(array, resolve(1), fromIndex); @@ -13320,7 +13320,7 @@ QUnit.test('should accept a falsey `collection` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyArray); + var expected = lodashStable.map(falsey, mockArray); var actual = lodashStable.map(falsey, function(collection, index) { try { @@ -13532,7 +13532,7 @@ QUnit.test('`_.' + methodName + '` should accept a falsey `object` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyObject); + var expected = lodashStable.map(falsey, mockObject); var actual = lodashStable.map(falsey, function(object, index) { try { @@ -13609,7 +13609,7 @@ var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], source = new Foo, actual = lodashStable.map(objects, _.matches(source)), - expected = lodashStable.map(objects, alwaysTrue); + expected = lodashStable.map(objects, mockTrue); assert.deepEqual(actual, expected); }); @@ -13834,7 +13834,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysFalse), + expected = lodashStable.map(values, mockFalse), matches = _.matches({ 'a': 1 }); var actual = lodashStable.map(values, function(value, index) { @@ -13850,7 +13850,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysTrue), + expected = lodashStable.map(values, mockTrue), matches = _.matches({}); var actual = lodashStable.map(values, function(value, index) { @@ -13866,7 +13866,7 @@ assert.expect(1); var object = { 'a': 1 }, - expected = lodashStable.map(empties, alwaysTrue); + expected = lodashStable.map(empties, mockTrue); var actual = lodashStable.map(empties, function(value) { var matches = _.matches(value); @@ -14036,7 +14036,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { var matches = _.matchesProperty(path, 1); @@ -14074,7 +14074,7 @@ Foo.prototype.b = 2; var objects = [{ 'a': { 'a': 1 } }, { 'a': { 'a': 1, 'b': 2 } }], - expected = lodashStable.map(objects, alwaysTrue); + expected = lodashStable.map(objects, mockTrue); lodashStable.each(['a', ['a']], function(path) { assert.deepEqual(lodashStable.map(objects, _.matchesProperty(path, new Foo)), expected); @@ -14293,7 +14293,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); lodashStable.each(['constructor', ['constructor']], function(path) { var matches = _.matchesProperty(path, 1); @@ -14393,7 +14393,7 @@ QUnit.test('should return `NaN` when passing empty `array` values', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, alwaysNaN), + var expected = lodashStable.map(empties, mockNaN), actual = lodashStable.map(empties, _.mean); assert.deepEqual(actual, expected); @@ -14487,7 +14487,7 @@ QUnit.test('should not error if `resolver` is falsey', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(resolver, index) { try { @@ -14850,7 +14850,7 @@ function Foo() {} var values = [new Foo, new Boolean, new Date, Foo, new Number, new String, new RegExp], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { var object = _.merge({}, { 'value': value }); @@ -14869,7 +14869,7 @@ var props = ['0', 'a', 'buffer'], values = [[{ 'a': 1 }], { 'a': [1] }, typedArray], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value, index) { var key = props[index], @@ -14998,7 +14998,7 @@ var object1 = { 'el': document && document.createElement('div') }, object2 = { 'el': document && document.createElement('div') }, pairs = [[{}, object1], [object1, object2]], - expected = lodashStable.map(pairs, alwaysTrue); + expected = lodashStable.map(pairs, mockTrue); var actual = lodashStable.map(pairs, function(pair) { try { @@ -15093,7 +15093,7 @@ QUnit.test('should create a function that calls a method of a given object', function(assert) { assert.expect(4); - var object = { 'a': alwaysOne }; + var object = { 'a': mockOne }; lodashStable.each(['a', ['a']], function(path) { var method = _.method(path); @@ -15105,7 +15105,7 @@ QUnit.test('should work with deep property values', function(assert) { assert.expect(2); - var object = { 'a': { 'b': alwaysTwo } }; + var object = { 'a': { 'b': mockTwo } }; lodashStable.each(['a.b', ['a', 'b']], function(path) { var method = _.method(path); @@ -15131,7 +15131,7 @@ fn.toString = lodashStable.constant('fn'); var expected = [1, 1, 2, 2, 3, 3, 4, 4], - objects = [{ 'null': alwaysOne }, { 'undefined': alwaysTwo }, { 'fn': alwaysThree }, { '[object Object]': alwaysFour }], + objects = [{ 'null': mockOne }, { 'undefined': mockTwo }, { 'fn': mockThree }, { '[object Object]': mockFour }], values = [null, undefined, fn, {}]; var actual = lodashStable.transform(objects, function(result, object, index) { @@ -15149,7 +15149,7 @@ assert.expect(2); function Foo() {} - Foo.prototype.a = alwaysOne; + Foo.prototype.a = mockOne; lodashStable.each(['a', ['a']], function(path) { var method = _.method(path); @@ -15160,7 +15160,7 @@ QUnit.test('should use a key over a path', function(assert) { assert.expect(2); - var object = { 'a.b': alwaysOne, 'a': { 'b': alwaysTwo } }; + var object = { 'a.b': mockOne, 'a': { 'b': mockTwo } }; lodashStable.each(['a.b', ['a.b']], function(path) { var method = _.method(path); @@ -15248,7 +15248,7 @@ QUnit.test('should create a function that calls a method of a given key', function(assert) { assert.expect(4); - var object = { 'a': alwaysOne }; + var object = { 'a': mockOne }; lodashStable.each(['a', ['a']], function(path) { var methodOf = _.methodOf(object); @@ -15260,7 +15260,7 @@ QUnit.test('should work with deep property values', function(assert) { assert.expect(2); - var object = { 'a': { 'b': alwaysTwo } }; + var object = { 'a': { 'b': mockTwo } }; lodashStable.each(['a.b', ['a', 'b']], function(path) { var methodOf = _.methodOf(object); @@ -15286,7 +15286,7 @@ fn.toString = lodashStable.constant('fn'); var expected = [1, 1, 2, 2, 3, 3, 4, 4], - objects = [{ 'null': alwaysOne }, { 'undefined': alwaysTwo }, { 'fn': alwaysThree }, { '[object Object]': alwaysFour }], + objects = [{ 'null': mockOne }, { 'undefined': mockTwo }, { 'fn': mockThree }, { '[object Object]': mockFour }], values = [null, undefined, fn, {}]; var actual = lodashStable.transform(objects, function(result, object, index) { @@ -15304,7 +15304,7 @@ assert.expect(2); function Foo() {} - Foo.prototype.a = alwaysOne; + Foo.prototype.a = mockOne; lodashStable.each(['a', ['a']], function(path) { var methodOf = _.methodOf(new Foo); @@ -15315,7 +15315,7 @@ QUnit.test('should use a key over a path', function(assert) { assert.expect(2); - var object = { 'a.b': alwaysOne, 'a': { 'b': alwaysTwo } }; + var object = { 'a.b': mockOne, 'a': { 'b': mockTwo } }; lodashStable.each(['a.b', ['a.b']], function(path) { var methodOf = _.methodOf(object); @@ -15564,7 +15564,7 @@ if (!isNpm) { _.mixin(source); - _.a = alwaysB; + _.a = mockB; assert.strictEqual(_.a(array), 'b'); assert.strictEqual(_(array).a().value(), 'a'); @@ -15743,6 +15743,39 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('mock methods'); + + lodashStable.each(['mockTrue', 'mockFalse', 'mockArray', 'mockObject', 'mockString', 'noop'], function(methodName) { + var func = _[methodName]; + + var pair = ({ + 'mockArray': [[], 'an empty array'], + 'mockFalse': [false, '`false`'], + 'mockObject': [{}, 'an empty object'], + 'mockString': ['', 'an empty string'], + 'mockTrue': [true, '`true`'], + 'noop': [undefined, '`undefined`'] + })[methodName]; + + var values = Array(2).concat(empties, true, 1, 'a'), + expected = lodashStable.map(values, lodashStable.constant(pair[0])); + + QUnit.test('`_.' + methodName + '` should return ' + pair[1], function(assert) { + assert.expect(1); + + var actual = lodashStable.map(values, function(value, index) { + if (index < 2) { + return index ? func.call({}) : func(); + } + return func(value); + }); + + assert.deepEqual(actual, expected); + }); + }); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.multiply'); (function() { @@ -15937,25 +15970,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.noop'); - - (function() { - QUnit.test('should return `undefined`', function(assert) { - assert.expect(1); - - var values = empties.concat(true, new Date, _, 1, /x/, 'a'), - expected = lodashStable.map(values, noop); - - var actual = lodashStable.map(values, function(value, index) { - return index ? _.noop(value) : _.noop(); - }); - - assert.deepEqual(actual, expected); - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.noConflict'); (function() { @@ -16060,7 +16074,7 @@ assert.expect(2); var values = falsey, - expected = lodashStable.map(values, alwaysA); + expected = lodashStable.map(values, mockA); var actual = lodashStable.map(values, function(n) { return n ? _.nth(array, n) : _.nth(array); @@ -16069,7 +16083,7 @@ assert.deepEqual(actual, expected); values = ['1', 1.6]; - expected = lodashStable.map(values, alwaysB); + expected = lodashStable.map(values, mockB); actual = lodashStable.map(values, function(n) { return _.nth(array, n); @@ -16141,7 +16155,7 @@ assert.expect(2); var values = falsey, - expected = lodashStable.map(values, alwaysA); + expected = lodashStable.map(values, mockA); var actual = lodashStable.map(values, function(n) { var func = n ? _.nthArg(n) : _.nthArg(); @@ -16151,7 +16165,7 @@ assert.deepEqual(actual, expected); values = ['1', 1.6]; - expected = lodashStable.map(values, alwaysB); + expected = lodashStable.map(values, mockB); actual = lodashStable.map(values, function(n) { var func = _.nthArg(n); @@ -16497,7 +16511,7 @@ QUnit.test('should create a function that returns `true` if all predicates return truthy', function(assert) { assert.expect(1); - var over = _.overEvery(alwaysTrue, alwaysOne, alwaysA); + var over = _.overEvery(mockTrue, mockOne, mockA); assert.strictEqual(over(), true); }); @@ -16567,7 +16581,7 @@ QUnit.test('should flatten `predicates`', function(assert) { assert.expect(1); - var over = _.overEvery(alwaysTrue, [alwaysFalse]); + var over = _.overEvery(mockTrue, [mockFalse]); assert.strictEqual(over(), false); }); @@ -16605,10 +16619,10 @@ QUnit.test('should create a function that returns `true` if any predicates return truthy', function(assert) { assert.expect(2); - var over = _.overSome(alwaysFalse, alwaysOne, alwaysEmptyString); + var over = _.overSome(mockFalse, mockOne, mockString); assert.strictEqual(over(), true); - over = _.overSome(alwaysNull, alwaysA, alwaysZero); + over = _.overSome(mockNull, mockA, mockZero); assert.strictEqual(over(), true); }); @@ -16627,10 +16641,10 @@ QUnit.test('should return `false` if all predicates return falsey', function(assert) { assert.expect(2); - var over = _.overSome(alwaysFalse, alwaysFalse, alwaysFalse); + var over = _.overSome(mockFalse, mockFalse, mockFalse); assert.strictEqual(over(), false); - over = _.overSome(alwaysNull, alwaysZero, alwaysEmptyString); + over = _.overSome(mockNull, mockZero, mockString); assert.strictEqual(over(), false); }); @@ -16688,7 +16702,7 @@ QUnit.test('should flatten `predicates`', function(assert) { assert.expect(1); - var over = _.overSome(alwaysFalse, [alwaysTrue]); + var over = _.overSome(mockFalse, [mockTrue]); assert.strictEqual(over(), true); }); @@ -16749,7 +16763,7 @@ assert.expect(1); var values = [Object(string), { 'toString': lodashStable.constant(string) }], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { return _.pad(value, 6) === ' abc '; @@ -16789,7 +16803,7 @@ assert.expect(1); var values = [Object(string), { 'toString': lodashStable.constant(string) }], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { return _.padEnd(value, 6) === 'abc '; @@ -16829,7 +16843,7 @@ assert.expect(1); var values = [Object(string), { 'toString': lodashStable.constant(string) }], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { return _.padStart(value, 6) === ' abc'; @@ -16978,7 +16992,7 @@ QUnit.test('should coerce `radix` to a number', function(assert) { assert.expect(2); - var object = { 'valueOf': alwaysZero }; + var object = { 'valueOf': mockZero }; assert.strictEqual(_.parseInt('08', object), 8); assert.strictEqual(_.parseInt('0x20', object), 32); }); @@ -17372,8 +17386,8 @@ assert.expect(3); assert.deepEqual(_.partition([], identity), [[], []]); - assert.deepEqual(_.partition(array, alwaysTrue), [array, []]); - assert.deepEqual(_.partition(array, alwaysFalse), [[], array]); + assert.deepEqual(_.partition(array, mockTrue), [array, []]); + assert.deepEqual(_.partition(array, mockFalse), [[], array]); }); QUnit.test('should use `_.identity` when `predicate` is nullish', function(assert) { @@ -18031,7 +18045,7 @@ result[value] = 1; }, []); - var expected = lodashStable.map(values, alwaysOne), + var expected = lodashStable.map(values, mockOne), actual = _.pullAt(array, values); assert.deepEqual(actual, expected); @@ -18196,7 +18210,7 @@ assert.expect(1); var array = [1, 2, 3], - expected = lodashStable.map(array, alwaysTrue), + expected = lodashStable.map(array, mockTrue), randoms = lodashStable.map(array, _.random); var actual = lodashStable.map(randoms, function(result, index) { @@ -18887,7 +18901,7 @@ assert.strictEqual(_.repeat(string, '2'), 'abcabc'); assert.strictEqual(_.repeat(string, 2.6), 'abcabc'); - assert.strictEqual(_.repeat('*', { 'valueOf': alwaysThree }), '***'); + assert.strictEqual(_.repeat('*', { 'valueOf': mockThree }), '***'); }); QUnit.test('should coerce `string` to a string', function(assert) { @@ -18924,7 +18938,7 @@ QUnit.module('lodash.result'); (function() { - var object = { 'a': 1, 'b': alwaysB }; + var object = { 'a': 1, 'b': mockB }; QUnit.test('should invoke function values', function(assert) { assert.expect(1); @@ -18942,7 +18956,7 @@ QUnit.test('should invoke nested function values', function(assert) { assert.expect(2); - var value = { 'a': lodashStable.constant({ 'b': alwaysB }) }; + var value = { 'a': lodashStable.constant({ 'b': mockB }) }; lodashStable.each(['a.b', ['a', 'b']], function(path) { assert.strictEqual(_.result(value, path), 'b'); @@ -19569,7 +19583,7 @@ QUnit.test('should return an empty array for empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, alwaysEmptyArray); + var expected = lodashStable.map(empties, mockArray); var actual = lodashStable.transform(empties, function(result, value) { try { @@ -19914,7 +19928,7 @@ QUnit.test('should accept a falsey `object` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysZero); + var expected = lodashStable.map(falsey, mockZero); var actual = lodashStable.map(falsey, function(object, index) { try { @@ -20176,7 +20190,7 @@ QUnit.test('should return `false` for empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, alwaysFalse); + var expected = lodashStable.map(empties, mockFalse); var actual = lodashStable.map(empties, function(value) { try { @@ -20211,7 +20225,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value, index) { var array = [0, 0]; @@ -20220,7 +20234,7 @@ assert.deepEqual(actual, expected); - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); actual = lodashStable.map(values, function(value, index) { var array = [0, 1]; return index ? _.some(array, value) : _.some(array); @@ -20697,8 +20711,8 @@ QUnit.test('should accept a falsey `array` argument', function(assert) { assert.expect(1); - var spread = _.spread(alwaysTrue), - expected = lodashStable.map(falsey, alwaysTrue); + var spread = _.spread(mockTrue), + expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(array, index) { try { @@ -20801,7 +20815,7 @@ QUnit.test('should treat falsey `position` values as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(position) { return _.startsWith(string, 'a', position); @@ -21026,7 +21040,7 @@ QUnit.test('`_.' + methodName + '` should return `0` when passing empty `array` values', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, alwaysZero); + var expected = lodashStable.map(empties, mockZero); var actual = lodashStable.map(empties, function(value) { return func(value); @@ -21064,7 +21078,7 @@ QUnit.test('should accept a falsey `array` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyArray); + var expected = lodashStable.map(falsey, mockArray); var actual = lodashStable.map(falsey, function(array, index) { try { @@ -22029,7 +22043,7 @@ assert.expect(1); var values = [, null, undefined, ''], - expected = lodashStable.map(values, alwaysEmptyString), + expected = lodashStable.map(values, mockString), data = { 'a': 1 }; var actual = lodashStable.map(values, function(value, index) { @@ -22115,7 +22129,7 @@ var compiled = _.template('x'), values = [String(compiled), compiled.source], - expected = lodashStable.map(values, alwaysTrue); + expected = lodashStable.map(values, mockTrue); var actual = lodashStable.map(values, function(value) { return lodashStable.includes(value, '__p'); @@ -22147,7 +22161,7 @@ } catch (e) { values[1] = e.source; } - var expected = lodashStable.map(values, alwaysFalse); + var expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(values, function(value) { return lodashStable.includes(value, 'sourceURL'); @@ -22762,7 +22776,7 @@ assert.expect(1); var values = falsey.concat(-1, -Infinity), - expected = lodashStable.map(values, alwaysEmptyArray); + expected = lodashStable.map(values, mockArray); var actual = lodashStable.map(values, function(value, index) { return index ? _.times(value) : _.times(); @@ -23474,7 +23488,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysEmptyString); + expected = lodashStable.map(values, mockString); var actual = lodashStable.map(values, function(value, index) { return index ? _.toString(value) : _.toString(); @@ -23537,7 +23551,7 @@ var accumulators = [, null, undefined], object = new Foo, - expected = lodashStable.map(accumulators, alwaysTrue); + expected = lodashStable.map(accumulators, mockTrue); var iteratee = function(result, value, key) { result[key] = square(value); @@ -23575,7 +23589,7 @@ QUnit.test('should create regular arrays from typed arrays', function(assert) { assert.expect(1); - var expected = lodashStable.map(typedArrays, alwaysTrue); + var expected = lodashStable.map(typedArrays, mockTrue); var actual = lodashStable.map(typedArrays, function(type) { var Ctor = root[type], @@ -23646,7 +23660,7 @@ var Ctors = [Boolean, Boolean, Number, Number, Number, String, String], values = [false, true, 0, 1, NaN, '', 'a'], - expected = lodashStable.map(values, alwaysEmptyObject); + expected = lodashStable.map(values, mockObject); var results = lodashStable.map(values, function(value) { return _.transform(value); @@ -23654,7 +23668,7 @@ assert.deepEqual(results, expected); - expected = lodashStable.map(values, alwaysFalse); + expected = lodashStable.map(values, mockFalse); var actual = lodashStable.map(results, function(value, index) { return value instanceof Ctors[index]; @@ -23674,7 +23688,7 @@ QUnit.test('should create an empty object when given a falsey `object` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyObject); + var expected = lodashStable.map(falsey, mockObject); var actual = lodashStable.map(falsey, function(object, index) { return index ? _.transform(object) : _.transform(); @@ -23715,7 +23729,7 @@ return lodashStable.isObject(value) && !lodashStable.isElement(value); }); - var expected = lodashStable.map(objects, alwaysTrue); + var expected = lodashStable.map(objects, mockTrue); var actual = lodashStable.map(objects, function(object) { var Ctor = object.constructor, @@ -24664,7 +24678,7 @@ QUnit.test('should work with a `customizer` callback', function(assert) { assert.expect(1); - var actual = _.updateWith({ '0': {} }, '[0][1][2]', alwaysThree, function(value) { + var actual = _.updateWith({ '0': {} }, '[0][1][2]', mockThree, function(value) { return lodashStable.isObject(value) ? undefined : {}; }); @@ -24674,7 +24688,7 @@ QUnit.test('should work with a `customizer` that returns `undefined`', function(assert) { assert.expect(1); - var actual = _.updateWith({}, 'a[0].b.c', alwaysFour, noop); + var actual = _.updateWith({}, 'a[0].b.c', mockFour, noop); assert.deepEqual(actual, { 'a': [{ 'b': { 'c': 4 } }] }); }); }()); @@ -24836,7 +24850,7 @@ assert.expect(1); var operators = ['\xac', '\xb1', '\xd7', '\xf7'], - expected = lodashStable.map(operators, alwaysEmptyArray), + expected = lodashStable.map(operators, mockArray), actual = lodashStable.map(operators, _.words); assert.deepEqual(actual, expected); @@ -24851,7 +24865,7 @@ '\u205d', '\u205e' ]; - var expected = lodashStable.map(marks, alwaysEmptyArray), + var expected = lodashStable.map(marks, mockArray), actual = lodashStable.map(marks, _.words); assert.deepEqual(actual, expected); @@ -24949,7 +24963,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, alwaysA); + expected = lodashStable.map(values, mockA); var actual = lodashStable.map(values, function(value, index) { var wrapped = index ? _.wrap('a', value) : _.wrap('a'); @@ -25257,7 +25271,7 @@ QUnit.test('`_.' + methodName + '` should treat falsey values as empty arrays', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyArray); + var expected = lodashStable.map(falsey, mockArray); var actual = lodashStable.map(falsey, function(value) { return func([value, value, value]); @@ -25504,7 +25518,7 @@ assert.expect(1); if (!isNpm) { - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(value, index) { try { @@ -25546,7 +25560,7 @@ assert.expect(1); if (!isNpm) { - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(value, index) { try { @@ -25592,7 +25606,7 @@ assert.expect(1); if (!isNpm) { - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(value, index) { try { @@ -25634,7 +25648,7 @@ assert.expect(1); if (!isNpm) { - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(value, index) { try { @@ -25680,7 +25694,7 @@ assert.expect(1); if (!isNpm) { - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(value, index) { try { @@ -25722,7 +25736,7 @@ assert.expect(1); if (!isNpm) { - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(falsey, mockTrue); var actual = lodashStable.map(falsey, function(value, index) { try { @@ -26122,7 +26136,7 @@ assert.expect(1); var values = [, null, undefined, ''], - expected = lodashStable.map(values, alwaysEmptyString); + expected = lodashStable.map(values, mockString); var actual = lodashStable.map(values, function(value, index) { return index ? func(value) : func(); @@ -26226,12 +26240,12 @@ var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey); QUnit.test('should accept falsey arguments', function(assert) { - assert.expect(309); + assert.expect(314); - var emptyArrays = lodashStable.map(falsey, alwaysEmptyArray); + var arrays = lodashStable.map(falsey, mockArray); lodashStable.each(acceptFalsey, function(methodName) { - var expected = emptyArrays, + var expected = arrays, func = _[methodName], pass = true; @@ -26293,7 +26307,7 @@ assert.expect(24); lodashStable.each(rejectFalsey, function(methodName) { - var expected = lodashStable.map(falsey, alwaysTrue), + var expected = lodashStable.map(falsey, mockTrue), func = _[methodName]; var actual = lodashStable.map(falsey, function(value, index) {