|
9588 | 9588 | test('should provide the correct `predicate` arguments in a lazy chain sequence', 5, function() {
|
9589 | 9589 | if (!isNpm) {
|
9590 | 9590 | var args,
|
9591 |
| - array = _.range(0, LARGE_ARRAY_SIZE), |
| 9591 | + array = _.range(0, LARGE_ARRAY_SIZE + 1), |
9592 | 9592 | expected = [1, 0, _.map(array.slice(1), square)];
|
9593 | 9593 |
|
9594 | 9594 | _(array).slice(1).map(function(value, index, array) {
|
@@ -17092,14 +17092,14 @@
|
17092 | 17092 |
|
17093 | 17093 | test('should work when in a lazy chain sequence before `first` or `last`', 1, function() {
|
17094 | 17094 | if (!isNpm) {
|
17095 |
| - var array = _.range(0, LARGE_ARRAY_SIZE), |
17096 |
| - wrapped = _(array).slice(1).xor([LARGE_ARRAY_SIZE - 1, LARGE_ARRAY_SIZE]); |
| 17095 | + var array = _.range(0, LARGE_ARRAY_SIZE + 1), |
| 17096 | + wrapped = _(array).slice(1).xor([LARGE_ARRAY_SIZE, LARGE_ARRAY_SIZE + 1]); |
17097 | 17097 |
|
17098 | 17098 | var actual = _.map(['first', 'last'], function(methodName) {
|
17099 | 17099 | return wrapped[methodName]();
|
17100 | 17100 | });
|
17101 | 17101 |
|
17102 |
| - deepEqual(actual, [1, LARGE_ARRAY_SIZE]); |
| 17102 | + deepEqual(actual, [1, LARGE_ARRAY_SIZE + 1]); |
17103 | 17103 | }
|
17104 | 17104 | else {
|
17105 | 17105 | skipTest();
|
@@ -17501,80 +17501,106 @@
|
17501 | 17501 | QUnit.module('lodash(...).reverse');
|
17502 | 17502 |
|
17503 | 17503 | (function() {
|
17504 |
| - test('should return the wrapped reversed `array`', 3, function() { |
| 17504 | + var largeArray = _.range(0, LARGE_ARRAY_SIZE).concat(null), |
| 17505 | + smallArray = [0, 1, 2, null]; |
| 17506 | + |
| 17507 | + test('should return the wrapped reversed `array`', 6, function() { |
17505 | 17508 | if (!isNpm) {
|
17506 |
| - var array = [1, 2, 3], |
17507 |
| - wrapped = _(array).reverse(), |
17508 |
| - actual = wrapped.value(); |
| 17509 | + _.times(2, function(index) { |
| 17510 | + var array = (index ? largeArray : smallArray).slice(), |
| 17511 | + clone = array.slice(), |
| 17512 | + wrapped = _(array).reverse(), |
| 17513 | + actual = wrapped.value(); |
17509 | 17514 |
|
17510 |
| - ok(wrapped instanceof _); |
17511 |
| - strictEqual(actual, array); |
17512 |
| - deepEqual(actual, [3, 2, 1]); |
| 17515 | + ok(wrapped instanceof _); |
| 17516 | + strictEqual(actual, array); |
| 17517 | + deepEqual(actual, clone.slice().reverse()); |
| 17518 | + }); |
17513 | 17519 | }
|
17514 | 17520 | else {
|
17515 |
| - skipTest(3); |
| 17521 | + skipTest(6); |
17516 | 17522 | }
|
17517 | 17523 | });
|
17518 | 17524 | <
8000
br>
|
17519 |
| - test('should work in a lazy chain sequence', 1, function() { |
| 17525 | + test('should work in a lazy chain sequence', 4, function() { |
17520 | 17526 | if (!isNpm) {
|
17521 |
| - var array = _.range(0, LARGE_ARRAY_SIZE).concat(null), |
17522 |
| - actual = _(array).slice(1).reverse().value(); |
| 17527 | + _.times(2, function(index) { |
| 17528 | + var array = (index ? largeArray : smallArray).slice(), |
| 17529 | + expected = array.slice(), |
| 17530 | + actual = _(array).slice(1).reverse().value(); |
17523 | 17531 |
|
17524 |
| - deepEqual(actual, array.slice(1).reverse()); |
| 17532 | + deepEqual(actual, expected.slice(1).reverse()); |
| 17533 | + deepEqual(array, expected); |
| 17534 | + }); |
17525 | 17535 | }
|
17526 | 17536 | else {
|
17527 |
| - skipTest(); |
| 17537 | + skipTest(4); |
17528 | 17538 | }
|
17529 | 17539 | });
|
17530 | 17540 |
|
17531 |
| - test('should be lazy when in a lazy chain sequence', 2, function() { |
| 17541 | + test('should be lazy when in a lazy chain sequence', 3, function() { |
17532 | 17542 | if (!isNpm) {
|
17533 | 17543 | var spy = {
|
17534 | 17544 | 'toString': function() {
|
17535 | 17545 | throw new Error('spy was revealed');
|
17536 | 17546 | }
|
17537 | 17547 | };
|
17538 | 17548 |
|
| 17549 | + var array = largeArray.concat(spy), |
| 17550 | + expected = array.slice(); |
| 17551 | + |
17539 | 17552 | try {
|
17540 |
| - var array = _.range(0, LARGE_ARRAY_SIZE).concat(spy), |
17541 |
| - wrapped = _(array).slice(1).map(String).reverse(), |
| 17553 | + var wrapped = _(array).slice(1).map(String).reverse(), |
17542 | 17554 | actual = wrapped.last();
|
17543 | 17555 | } catch(e) {}
|
17544 | 17556 |
|
17545 | 17557 | ok(wrapped instanceof _);
|
17546 | 17558 | strictEqual(actual, '1');
|
| 17559 | + deepEqual(array, expected); |
17547 | 17560 | }
|
17548 | 17561 | else {
|
17549 |
| - skipTest(2); |
| 17562 | + skipTest(3); |
17550 | 17563 | }
|
17551 | 17564 | });
|
17552 | 17565 |
|
17553 |
| - test('should work in a hybrid chain sequence', 4, function() { |
| 17566 | + test('should work in a hybrid chain sequence', 8, function() { |
17554 | 17567 | if (!isNpm) {
|
17555 |
| - var array = [1, 2, 3, null]; |
| 17568 | + _.times(2, function(index) { |
| 17569 | + var clone = (index ? largeArray : smallArray).slice(); |
17556 | 17570 |
|
17557 |
| - _.each(['map', 'filter'], function(methodName) { |
17558 |
| - var actual = _(array)[methodName](_.identity).thru(_.compact).reverse().value(); |
17559 |
| - deepEqual(actual, [3, 2, 1]); |
| 17571 | + _.each(['map', 'filter'], function(methodName) { |
| 17572 | + var array = clone.slice(), |
| 17573 | + expected = clone.slice(1, -1).reverse(), |
| 17574 | + actual = _(array)[methodName](_.identity).thru(_.compact).reverse().value(); |
17560 | 17575 |
|
17561 |
| - actual = _(array).thru(_.compact)[methodName](_.identity).pull(1).push(4).reverse().value(); |
17562 |
| - deepEqual(actual, [4, 3, 2]); |
| 17576 | + deepEqual(actual, expected); |
| 17577 | + |
| 17578 | + array = clone.slice(); |
| 17579 | + actual = _(array).thru(_.compact)[methodName](_.identity).pull(1).push(3).reverse().value(); |
| 17580 | + |
| 17581 | + deepEqual(actual, [3].concat(expected.slice(0, -1))); |
| 17582 | + }); |
17563 | 17583 | });
|
17564 | 17584 | }
|
17565 | 17585 | else {
|
17566 |
| - skipTest(4); |
| 17586 | + skipTest(8); |
17567 | 17587 | }
|
17568 | 17588 | });
|
17569 | 17589 |
|
17570 |
| - test('should track the `__chain__` value of a wrapper', 2, function() { |
| 17590 | + test('should track the `__chain__` value of a wrapper', 6, function() { |
17571 | 17591 | if (!isNpm) {
|
17572 |
| - var wrapped = _([1, 2, 3]).chain().reverse().first(); |
17573 |
| - ok(wrapped instanceof _); |
17574 |
| - strictEqual(wrapped.value(), 3); |
| 17592 | + _.times(2, function(index) { |
| 17593 | + var array = (index ? largeArray : smallArray).slice(), |
| 17594 | + expected = array.slice().reverse(), |
| 17595 | + wrapped = _(array).chain().reverse().first(); |
| 17596 | + |
| 17597 | + ok(wrapped instanceof _); |
| 17598 | + strictEqual(wrapped.value(), _.first(expected)); |
| 17599 | + deepEqual(array, expected); |
| 17600 | + }); |
17575 | 17601 | }
|
17576 | 17602 | else {
|
17577 |
| - skipTest(2); |
| 17603 | + skipTest(6); |
17578 | 17604 | }
|
17579 | 17605 | });
|
17580 | 17606 | }());
|
|
0 commit comments