mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Adjust how tests are skipped in loops so values may be added without adjusting the skip counts.
This commit is contained in:
143
test/test.js
143
test/test.js
@@ -1790,8 +1790,9 @@
|
|||||||
_.each(typedArrays, function(type) {
|
_.each(typedArrays, function(type) {
|
||||||
test('`_.' + methodName + '` should clone ' + type + ' arrays', 10, function() {
|
test('`_.' + methodName + '` should clone ' + type + ' arrays', 10, function() {
|
||||||
var Ctor = root[type];
|
var Ctor = root[type];
|
||||||
if (Ctor) {
|
|
||||||
_.times(2, function(index) {
|
_.times(2, function(index) {
|
||||||
|
if (Ctor) {
|
||||||
var buffer = new ArrayBuffer(24),
|
var buffer = new ArrayBuffer(24),
|
||||||
array = index ? new Ctor(buffer, 8, 1) : new Ctor(buffer),
|
array = index ? new Ctor(buffer, 8, 1) : new Ctor(buffer),
|
||||||
actual = func(array);
|
actual = func(array);
|
||||||
@@ -1801,11 +1802,11 @@
|
|||||||
strictEqual(actual.buffer === array.buffer, !isDeep);
|
strictEqual(actual.buffer === array.buffer, !isDeep);
|
||||||
strictEqual(actual.byteOffset, array.byteOffset);
|
strictEqual(actual.byteOffset, array.byteOffset);
|
||||||
strictEqual(actual.length, array.length);
|
strictEqual(actual.length, array.length);
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
else {
|
skipTest(5);
|
||||||
skipTest(10);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -4178,10 +4179,10 @@
|
|||||||
|
|
||||||
test('should work with extremely large arrays', 3, function() {
|
test('should work with extremely large arrays', 3, function() {
|
||||||
// Test in modern browsers only to avoid browser hangs.
|
// Test in modern browsers only to avoid browser hangs.
|
||||||
if (freeze) {
|
_.times(3, function(index) {
|
||||||
var expected = Array(5e5);
|
if (freeze) {
|
||||||
|
var expected = Array(5e5);
|
||||||
|
|
||||||
_.times(3, function(index) {
|
|
||||||
try {
|
try {
|
||||||
if (index) {
|
if (index) {
|
||||||
var actual = actual == 1 ? _.flatten([expected], true) : _.flattenDeep([expected]);
|
var actual = actual == 1 ? _.flatten([expected], true) : _.flattenDeep([expected]);
|
||||||
@@ -4192,11 +4193,11 @@
|
|||||||
} catch(e) {
|
} catch(e) {
|
||||||
ok(false, e.message);
|
ok(false, e.message);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
else {
|
skipTest();
|
||||||
skipTest(3);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work with empty arrays', 3, function() {
|
test('should work with empty arrays', 3, function() {
|
||||||
@@ -4790,22 +4791,24 @@
|
|||||||
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 });
|
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should not assign the `customizer` result if it is the same as the destination value', 1, function() {
|
test('`_.' + methodName + '` should not assign the `customizer` result if it is the same as the destination value', 3, function() {
|
||||||
if (defineProperty) {
|
_.each(['a', ['a'], { 'a': 1 }], function(value) {
|
||||||
var object = {},
|
if (defineProperty) {
|
||||||
pass = true;
|
var object = {},
|
||||||
|
pass = true;
|
||||||
|
|
||||||
defineProperty(object, 'a', {
|
defineProperty(object, 'a', {
|
||||||
'get': _.constant({}),
|
'get': _.constant(value),
|
||||||
'set': function() { pass = false; }
|
'set': function() { pass = false; }
|
||||||
});
|
});
|
||||||
|
|
||||||
func(object, { 'a': object.a }, _.identity);
|
func(object, { 'a': value }, _.identity);
|
||||||
ok(pass);
|
ok(pass);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest();
|
skipTest();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -5321,19 +5324,17 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('`_.uniq` should work with a custom `_.indexOf` method', 6, function() {
|
test('`_.uniq` should work with a custom `_.indexOf` method', 6, function() {
|
||||||
if (!isModularize) {
|
_.each([false, true, _.identity], function(param) {
|
||||||
_.indexOf = custom;
|
if (!isModularize) {
|
||||||
|
_.indexOf = custom;
|
||||||
_.each([false, true, _.identity], function(param) {
|
|
||||||
deepEqual(_.uniq(array, param), array.slice(0, 3));
|
deepEqual(_.uniq(array, param), array.slice(0, 3));
|
||||||
deepEqual(_.uniq(largeArray, param), [largeArray[0]]);
|
deepEqual(_.uniq(largeArray, param), [largeArray[0]]);
|
||||||
});
|
_.indexOf = indexOf;
|
||||||
|
}
|
||||||
_.indexOf = indexOf;
|
else {
|
||||||
}
|
skipTest();
|
||||||
else {
|
}
|
||||||
skipTest(6);
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
@@ -7452,14 +7453,14 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should not error on host objects (test in IE)', 15, function() {
|
test('should not error on host objects (test in IE)', 15, function() {
|
||||||
if (xml) {
|
var funcs = [
|
||||||
var funcs = [
|
'isArguments', 'isArray', 'isBoolean', 'isDate', 'isElement',
|
||||||
'isArguments', 'isArray', 'isBoolean', 'isDate', 'isElement',
|
'isError', 'isFinite', 'isFunction', 'isNaN', 'isNull', 'isNumber',
|
||||||
'isError', 'isFinite', 'isFunction', 'isNaN', 'isNull', 'isNumber',
|
'isObject', 'isRegExp', 'isString', 'isUndefined'
|
||||||
'isObject', 'isRegExp', 'isString', 'isUndefined'
|
];
|
||||||
];
|
|
||||||
|
|
||||||
_.each(funcs, function(methodName) {
|
_.each(funcs, function(methodName) {
|
||||||
|
if (xml) {
|
||||||
var pass = true;
|
var pass = true;
|
||||||
try {
|
try {
|
||||||
_[methodName](xml);
|
_[methodName](xml);
|
||||||
@@ -7467,11 +7468,11 @@
|
|||||||
pass = false;
|
pass = false;
|
||||||
}
|
}
|
||||||
ok(pass, '`_.' + methodName + '` should not error');
|
ok(pass, '`_.' + methodName + '` should not error');
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
else {
|
skipTest();
|
||||||
skipTest(15);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
@@ -8803,8 +8804,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should not return the existing wrapped value when chaining', 2, function() {
|
test('should not return the existing wrapped value when chaining', 2, function() {
|
||||||
if (!isNpm) {
|
_.each([_, Wrapper], function(func) {
|
||||||
_.each([_, Wrapper], function(func) {
|
if (!isNpm) {
|
||||||
if (func === _) {
|
if (func === _) {
|
||||||
var wrapped = _(source),
|
var wrapped = _(source),
|
||||||
actual = wrapped.mixin();
|
actual = wrapped.mixin();
|
||||||
@@ -8820,11 +8821,11 @@
|
|||||||
delete func.prototype.a;
|
delete func.prototype.a;
|
||||||
delete func.b;
|
delete func.b;
|
||||||
delete func.prototype.b;
|
delete func.prototype.b;
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
else {
|
skipTest();
|
||||||
skipTest(2);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should produce methods that work in a lazy chain sequence', 1, function() {
|
test('should produce methods that work in a lazy chain sequence', 1, function() {
|
||||||
@@ -12224,20 +12225,25 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should support a `leading` option', 4, function() {
|
test('should support a `leading` option', 4, function() {
|
||||||
if (!(isRhino && isModularize)) {
|
_.each([true, { 'leading': true }], function(options) {
|
||||||
_.each([true, { 'leading': true }], function(options) {
|
if (!(isRhino && isModularize)) {
|
||||||
var withLeading = _.throttle(_.identity, 32, options);
|
var withLeading = _.throttle(_.identity, 32, options);
|
||||||
strictEqual(withLeading('a'), 'a');
|
strictEqual(withLeading('a'), 'a');
|
||||||
});
|
}
|
||||||
|
else {
|
||||||
|
skiTest();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_.each([false, { 'leading': false }], function(options) {
|
_.each([false, { 'leading': false }], function(options) {
|
||||||
|
if (!(isRhino && isModularize)) {
|
||||||
var withoutLeading = _.throttle(_.identity, 32, options);
|
var withoutLeading = _.throttle(_.identity, 32, options);
|
||||||
strictEqual(withoutLeading('a'), undefined);
|
strictEqual(withoutLeading('a'), undefined);
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
else {
|
skipTest();
|
||||||
skipTest(4);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('should support a `trailing` option', 6, function() {
|
asyncTest('should support a `trailing` option', 6, function() {
|
||||||
@@ -13731,7 +13737,6 @@
|
|||||||
|
|
||||||
_.each(funcs, function(methodName) {
|
_.each(funcs, function(methodName) {
|
||||||
test('`_(...).' + methodName + '` should return a new wrapper', 2, function() {
|
test('`_(...).' + methodName + '` should return a new wrapper', 2, function() {
|
||||||
|
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var array = [1, 2, 3],
|
var array = [1, 2, 3],
|
||||||
wrapped = _(array),
|
wrapped = _(array),
|
||||||
|
|||||||
Reference in New Issue
Block a user