|
7775 | 7775 | });
|
7776 | 7776 | });
|
7777 | 7777 |
|
7778 |
| - QUnit.test('`_.' + methodName + '` should not use the `hasOwnProperty` method of the object', function(assert) { |
| 7778 | + QUnit.test('`_.' + methodName + '` should not use the `hasOwnProperty` method of `object`', function(assert) { |
7779 | 7779 | assert.expect(1);
|
7780 | 7780 |
|
7781 | 7781 | var object = { 'hasOwnProperty': null, 'a': 1 };
|
|
7797 | 7797 | });
|
7798 | 7798 |
|
7799 | 7799 | QUnit.test('`_.' + methodName + '` should coerce `path` to a string', function(assert) {
|
7800 |
| - assert.expect(1); |
| 7800 | + assert.expect(2); |
7801 | 7801 |
|
7802 | 7802 | function fn() {}
|
7803 | 7803 | fn.toString = lodashStable.constant('fn');
|
7804 | 7804 |
|
7805 |
| - var expected = [1, 1, 2, 2, 3, 3, 4, 4], |
7806 |
| - objects = [{ 'null': 1 }, { 'undefined': 2 }, { 'fn': 3 }, { '[object Object]': 4 }], |
7807 |
| - values = [null, undefined, fn, {}]; |
| 7805 | + var object = { 'null': 1 , 'undefined': 2, 'fn': 3, '[object Object]': 4 }, |
| 7806 | + paths = [null, undefined, fn, {}], |
| 7807 | + expected = lodashStable.map(paths, stubTrue); |
7808 | 7808 |
|
7809 |
| - var actual = lodashStable.transform(objects, function(result, object, index) { |
7810 |
| - var key = values[index]; |
7811 |
| - lodashStable.each([key, [key]], function(path) { |
7812 |
| - var prop = _.property(key); |
7813 |
| - result.push(prop(object)); |
| 7809 | + lodashStable.times(2, function(index) { |
| 7810 | + var actual = lodashStable.map(paths, function(path) { |
| 7811 | + return func(object, index ? [path] : path); |
7814 | 7812 | });
|
7815 |
| - }); |
7816 | 7813 |
|
7817 |
| - assert.deepEqual(actual, expected); |
| 7814 | + assert.deepEqual(actual, expected); |
| 7815 | + }); |
7818 | 7816 | });
|
7819 | 7817 |
|
7820 | 7818 | QUnit.test('`_.' + methodName + '` should work with `arguments` objects', function(assert) {
|
|
7876 | 7874 | });
|
7877 | 7875 | });
|
7878 | 7876 |
|
7879 |
| - QUnit.test('`_.' + methodName + '` should return `' + (isHas ? 'false' : 'true') + '` for inherited properties', function(assert) { |
7880 |
| - assert.expect(2); |
7881 |
| - |
7882 |
| - function Foo() {} |
7883 |
| - Foo.prototype.a = 1; |
7884 |
| - |
7885 |
| - lodashStable.each(['a', ['a']], function(path) { |
7886 |
| - assert.strictEqual(func(new Foo, path), !isHas); |
7887 |
| - }); |
7888 |
| - }); |
7889 |
| - |
7890 |
| - QUnit.test('`_.' + methodName + '` should return `' + (isHas ? 'false' : 'true') + '` for nested inherited properties', function(assert) { |
7891 |
| - assert.expect(2); |
7892 |
| - |
7893 |
| - function Foo() {} |
7894 |
| - Foo.prototype.a = { 'b': 1 }; |
7895 |
| - |
7896 |
| - lodashStable.each(['a.b', ['a', 'b']], function(path) { |
7897 |
| - assert.strictEqual(func(new Foo, path), !isHas); |
7898 |
| - }); |
7899 |
| - }); |
7900 |
| - |
7901 | 7877 | QUnit.test('`_.' + methodName + '` should return `true` for indexes of sparse values', function(assert) {
|
7902 | 7878 | assert.expect(1);
|
7903 | 7879 |
|
|
7926 | 7902 | assert.deepEqual(actual, expected);
|
7927 | 7903 | });
|
7928 | 7904 |
|
| 7905 | + QUnit.test('`_.' + methodName + '` should return `' + (isHas ? 'false' : 'true') + '` for inherited properties', function(assert) { |
| 7906 | + assert.expect(2); |
| 7907 | + |
| 7908 | + function Foo() {} |
| 7909 | + Foo.prototype.a = 1; |
| 7910 | + |
| 7911 | + lodashStable.each(['a', ['a']], function(path) { |
| 7912 | + assert.strictEqual(func(new Foo, path), !isHas); |
| 7913 | + }); |
| 7914 | + }); |
| 7915 | + |
| 7916 | + QUnit.test('`_.' + methodName + '` should return `' + (isHas ? 'false' : 'true') + '` for nested inherited properties', function(assert) { |
| 7917 | + assert.expect(2); |
| 7918 | + |
| 7919 | + function Foo() {} |
| 7920 | + Foo.prototype.a = { 'b': 1 }; |
| 7921 | + |
| 7922 | + lodashStable.each(['a.b', ['a', 'b']], function(path) { |
| 7923 | + assert.strictEqual(func(new Foo, path), !isHas); |
| 7924 | + }); |
| 7925 | + }); |
| 7926 | + |
7929 | 7927 | QUnit.test('`_.' + methodName + '` should return `false` when `object` is nullish', function(assert) {
|
7930 | 7928 | assert.expect(2);
|
7931 | 7929 |
|
@@ -14090,28 +14088,24 @@
|
14090 | 14088 | assert.deepEqual(actual, expected);
|
14091 | 14089 | });
|
14092 | 14090 |
|
14093 |
| - QUnit.test('should coerce key to a string', function(assert) { |
14094 |
| - assert.expect(1); |
| 14091 | + QUnit.test('should coerce `path` to a string', function(assert) { |
| 14092 | + assert.expect(2); |
14095 | 14093 |
|
14096 | 14094 | function fn() {}
|
14097 | 14095 | fn.toString = lodashStable.constant('fn');
|
14098 | 14096 |
|
14099 |
| - var objects = [{ 'null': 1 }, { 'undefined': 2 }, { 'fn': 3 }, { '[object Object]': 4 }], |
14100 |
| - values = [null, undefined, fn, {}]; |
| 14097 | + var object = { 'null': 1, 'undefined': 2, 'fn': 3, '[object Object]': 4 }, |
| 14098 | + paths = [null, undefined, fn, {}], |
| 14099 | + expected = lodashStable.map(paths, stubTrue); |
14101 | 14100 |
|
14102 |
| - var expected = lodashStable.transform(values, function(result) { |
14103 |
| - result.push(true, true); |
14104 |
| - }); |
14105 |
| - |
14106 |
| - var actual = lodashStable.transform(objects, function(result, object, index) { |
14107 |
| - var key = values[index]; |
14108 |
| - lodashStable.each([key, [key]], function(path) { |
14109 |
| - var matches = _.matchesProperty(path, object[key]); |
14110 |
| - result.push(matches(object)); |
| 14101 | + lodashStable.times(2, function(index) { |
| 14102 | + var actual = lodashStable.map(paths, function(path) { |
| 14103 | + var matches = _.matchesProperty(index ? [path] : path, object[path]); |
| 14104 | + return matches(object); |
14111 | 14105 | });
|
14112 |
| - }); |
14113 | 14106 |
|
14114 |
| - assert.deepEqual(actual, expected); |
| 14107 | + assert.deepEqual(actual, expected); |
| 14108 | + }); |
14115 | 14109 | });
|
14116 | 14110 |
|
14117 | 14111 | QUnit.test('should match a key over a path', function(assert) {
|
@@ -15254,25 +15248,24 @@
|
15254 | 15248 | });
|
15255 | 15249 | });
|
15256 | 15250 |
|
15257 |
| - QUnit.test('should coerce key to a string', function(assert) { |
15258 |
| - assert.expect(1); |
| 15251 | + QUnit.test('should coerce `path` to a string', function(assert) { |
| 15252 | + assert.expect(2); |
15259 | 15253 |
|
15260 | 15254 | function fn() {}
|
15261 | 15255 | fn.toString = lodashStable.constant('fn');
|
15262 | 15256 |
|
15263 |
| - var expected = [1, 1, 2, 2, 3, 3, 4, 4], |
15264 |
| - objects = [{ 'null': stubOne }, { 'undefined': stubTwo }, { 'fn': stubThree }, { '[object Object]': stubFour }], |
15265 |
| - values = [null, undefined, fn, {}]; |
| 15257 | + var expected = [1, 2, 3, 4], |
| 15258 | + object = { 'null': stubOne, 'undefined': stubTwo, 'fn': stubThree, '[object Object]': stubFour }, |
| 15259 | + paths = [null, undefined, fn, {}]; |
15266 | 15260 |
|
15267 |
| - var actual = lodashStable.transform(objects, function(result, object, index) { |
15268 |
| - var key = values[index]; |
15269 |
| - lodashStable.each([key, [key]], function(path) { |
15270 |
| - var method = _.method(key); |
15271 |
| - result.push(method(object)); |
| 15261 | + lodashStable.times(2, function(index) { |
| 15262 | + var actual = lodashStable.map(paths, function(path) { |
| 15263 | + var method = _.method(index ? [path] : path); |
| 15264 | + return method(object); |
15272 | 15265 | });
|
15273 |
| - }); |
15274 | 15266 |
|
15275 |
| - assert.deepEqual(actual, expected); |
| 15267 | + assert.deepEqual(actual, expected); |
| 15268 | + }); |
15276 | 15269 | });
|
15277 | 15270 |
|
15278 | 15271 | QUnit.test('should work with inherited property values', function(assert) {
|
@@ -15409,25 +15402,24 @@
|
15409 | 15402 | });
|
15410 | 15403 | });
|
15411 | 15404 |
|
15412 |
| - QUnit.test('should coerce key to a string', function(assert) { |
15413 |
| - assert.expect(1); |
| 15405 | + QUnit.test('should coerce `path` to a string', function(assert) { |
| 15406 | + assert.expect(2); |
15414 | 15407 |
|
15415 | 15408 | function fn() {}
|
15416 | 15409 | fn.toString = lodashStable.constant('fn');
|
15417 | 15410 |
|
15418 |
| - var expected = [1, 1, 2, 2, 3, 3, 4, 4], |
15419 |
| - objects = [{ 'null': stubOne }, { 'undefined': stubTwo }, { 'fn': stubThree }, { '[object Object]': stubFour }], |
15420 |
| - values = [null, undefined, fn, {}]; |
| 15411 | + var expected = [1, 2, 3, 4], |
| 15412 | + object = { 'null': stubOne, 'undefined': stubTwo, 'fn': stubThree, '[object Object]': stubFour }, |
| 15413 | + paths = [null, undefined, fn, {}]; |
15421 | 15414 |
|
15422 |
| - var actual = lodashStable.transform(objects, function(result, object, index) { |
15423 |
| - var key = values[index]; |
15424 |
| - lodashStable.each([key, [key]], function(path) { |
| 15415 | + lodashStable.times(2, function(index) { |
| 15416 | + var actual = lodashStable.map(paths, function(path) { |
15425 | 15417 | var methodOf = _.methodOf(object);
|
15426 |
| - result.push(methodOf(key)); |
| 15418 | + return methodOf(index ? [path] : path); |
15427 | 15419 | });
|
15428 |
| - }); |
15429 | 15420 |
|
15430 |
| - assert.deepEqual(actual, expected); |
| 15421 | + assert.deepEqual(actual, expected); |
| 15422 | + }); |
15431 | 15423 | });
|
15432 | 15424 |
|
15433 | 15425 | QUnit.test('should work with inherited property values', function(assert) {
|
@@ -17807,24 +17799,24 @@
|
17807 | 17799 | assert.deepEqual(actual, ['a', 'a', 'b', 'b']);
|
17808 | 17800 | });
|
17809 | 17801 |
|
17810 |
| - QUnit.test('should coerce key to a string', function(assert) { |
17811 |
| - assert.expect(1); |
| 17802 | + QUnit.test('should coerce `path` to a string', function(assert) { |
| 17803 | + assert.expect(2); |
17812 | 17804 |
|
17813 | 17805 | function fn() {}
|
17814 | 17806 | fn.toString = lodashStable.constant('fn');
|
17815 | 17807 |
|
17816 |
| - var objects = [{ 'null': 1 }, { 'undefined': 2 }, { 'fn': 3 }, { '[object Object]': 4 }], |
17817 |
| - values = [null, undefined, fn, {}]; |
| 17808 | + var expected = [1, 2, 3, 4], |
| 17809 | + object = { 'null': 1, 'undefined': 2, 'fn': 3, '[object Object]': 4 }, |
| 17810 | + paths = [null, undefined, fn, {}]; |
17818 | 17811 |
|
17819 |
| - var actual = lodashStable.transform(objects, function(result, object, index) { |
17820 |
| - var key = values[index]; |
17821 |
| - lodashStable.each([key, [key]], function(path) { |
17822 |
| - var prop = _.property(key); |
17823 |
| - result.push(prop(object)); |
| 17812 | + lodashStable.times(2, function(index) { |
| 17813 | + var actual = lodashStable.map(paths, function(path) { |
| 17814 | + var prop = _.property(index ? [path] : path); |
| 17815 | + return prop(object); |
17824 | 17816 | });
|
17825 |
| - }); |
17826 | 17817 |
|
17827 |
| - assert.deepEqual(actual, [1, 1, 2, 2, 3, 3, 4, 4]); |
| 17818 | + assert.deepEqual(actual, expected); |
| 17819 | + }); |
17828 | 17820 | });
|
17829 | 17821 |
|
17830 | 17822 | QUnit.test('should pluck a key over a path', function(assert) {
|
@@ -17952,24 +17944,24 @@
|
17952 | 17944 | assert.deepEqual(actual, ['a', 'a', 'b', 'b']);
|
17953 | 17945 | });
|
17954 | 17946 |
|
17955 |
| - QUnit.test('should coerce key to a string', function(assert) { |
17956 |
| - assert.expect(1); |
| 17947 | + QUnit.test('should coerce `path` to a string', function(assert) { |
| 17948 | + assert.expect(2); |
17957 | 17949 |
|
17958 | 17950 | function fn() {}
|
17959 | 17951 | fn.toString = lodashStable.constant('fn');
|
17960 | 17952 |
|
17961 |
| - var objects = [{ 'null': 1 }, { 'undefined': 2 }, { 'fn': 3 }, { '[object Object]': 4 }], |
17962 |
| - values = [null, undefined, fn, {}]; |
| 17953 | + var expected = [1, 2, 3, 4], |
| 17954 | + object = { 'null': 1, 'undefined': 2, 'fn': 3, '[object Object]': 4 }, |
| 17955 | + paths = [null, undefined, fn, {}]; |
17963 | 17956 |
|
17964 |
| - var actual = lodashStable.transform(objects, function(result, object, index) { |
17965 |
| - var key = values[index]; |
17966 |
| - lodashStable.each([key, [key]], function(path) { |
| 17957 | + lodashStable.times(2, function(index) { |
| 17958 | + var actual = lodashStable.map(paths, function(path) { |
17967 | 17959 | var propOf = _.propertyOf(object);
|
17968 |
| - result.push(propOf(key)); |
| 17960 | + return propOf(index ? [path] : path); |
17969 | 17961 | });
|
17970 |
| - }); |
17971 | 17962 |
|
17972 |
| - assert.deepEqual(actual, [1, 1, 2, 2, 3, 3, 4, 4]); |
| 17963 | + assert.deepEqual(actual, expected); |
| 17964 | + }); |
17973 | 17965 | });
|
17974 | 17966 |
|
17975 | 17967 | QUnit.test('should pluck a key over a path', function(assert) {
|
@@ -19325,25 +19317,19 @@
|
19325 | 19317 | });
|
19326 | 19318 |
|
19327 | 19319 | QUnit.test('`_.' + methodName + '` should return the default value for `undefined` values', function(assert) {
|
19328 |
| - assert.expect(1); |
| 19320 | + assert.expect(2); |
19329 | 19321 |
|
19330 | 19322 | var object = { 'a': {} },
|
19331 |
| - values = empties.concat(true, new Date, 1, /x/, 'a'); |
19332 |
| - |
19333 |
| - var expected = lodashStable.transform(values, function(result, value) { |
19334 |
| - result.push(value, value, value, value); |
19335 |
| - }); |
| 19323 | + values = empties.concat(true, new Date, 1, /x/, 'a'), |
| 19324 | + expected = lodashStable.map(values, function(value) { return [value, value]; }); |
19336 | 19325 |
|
19337 |
| - var actual = lodashStable.transform(values, function(result, value) { |
19338 |
| - lodashStable.each(['a.b', ['a', 'b']], function(path) { |
19339 |
| - result.push( |
19340 |
| - func(object, path, value), |
19341 |
| - func(null, path, value) |
19342 |
| - ); |
| 19326 | + lodashStable.each(['a.b', ['a', 'b']], function(path) { |
| 19327 | + var actual = lodashStable.map(values, function(value) { |
| 19328 | + return [func(object, path, value), func(null, path, value)]; |
19343 | 19329 | });
|
19344 |
| - }); |
19345 | 19330 |
|
19346 |
| - assert.deepEqual(actual, expected); |
| 19331 | + assert.deepEqual(actual, expected); |
| 19332 | + }); |
19347 | 19333 | });
|
19348 | 19334 |
|
19349 | 19335 | QUnit.test('`_.' + methodName + '` should return the default value when `path` is empty', function(assert) {
|
|