Adjust how tests are skipped in loops so values may be added without adjusting the skip counts.

This commit is contained in:
John-David Dalton
2014-12-27 20:27:17 -06:00
parent fa2058ec77
commit 3453236830

View File

@@ -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,13 +1802,13 @@
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(10); skipTest(5);
} }
}); });
}); });
});
test('`_.' + methodName + '` should clone problem JScript properties (test in IE < 9)', 2, function() { test('`_.' + methodName + '` should clone problem JScript properties (test in IE < 9)', 2, function() {
var actual = func(shadowObject); var actual = func(shadowObject);
@@ -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.
_.times(3, function(index) {
if (freeze) { if (freeze) {
var expected = Array(5e5); 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,12 +4193,12 @@
} catch(e) { } catch(e) {
ok(false, e.message); ok(false, e.message);
} }
});
} }
else { else {
skipTest(3); skipTest();
} }
}); });
});
test('should work with empty arrays', 3, function() { test('should work with empty arrays', 3, function() {
var array = [[], [[]], [[], [[[]]]]], var array = [[], [[]], [[], [[[]]]]],
@@ -4790,17 +4791,18 @@
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() {
_.each(['a', ['a'], { 'a': 1 }], function(value) {
if (defineProperty) { if (defineProperty) {
var object = {}, var object = {},
pass = true; 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 {
@@ -4808,6 +4810,7 @@
} }
}); });
}); });
});
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@@ -5321,20 +5324,18 @@
}); });
test('`_.uniq` should work with a custom `_.indexOf` method', 6, function() { test('`_.uniq` should work with a custom `_.indexOf` method', 6, function() {
_.each([false, true, _.identity], function(param) {
if (!isModularize) { if (!isModularize) {
_.indexOf = custom; _.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 { else {
skipTest(6); skipTest();
} }
}); });
});
}()); }());
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@@ -7452,7 +7453,6 @@
}); });
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',
@@ -7460,6 +7460,7 @@
]; ];
_.each(funcs, function(methodName) { _.each(funcs, function(methodName) {
if (xml) {
var pass = true; var pass = true;
try { try {
_[methodName](xml); _[methodName](xml);
@@ -7467,12 +7468,12 @@
pass = false; pass = false;
} }
ok(pass, '`_.' + methodName + '` should not error'); ok(pass, '`_.' + methodName + '` should not error');
});
} }
else { else {
skipTest(15); skipTest();
} }
}); });
});
}()); }());
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@@ -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,12 +8821,12 @@
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(2); skipTest();
} }
}); });
});
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() {
if (!isNpm) { if (!isNpm) {
@@ -12224,21 +12225,26 @@
}); });
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(4); skipTest();
} }
}); });
});
asyncTest('should support a `trailing` option', 6, function() { asyncTest('should support a `trailing` option', 6, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
@@ -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),