More consistent use of num argument in unit tests.

Former-commit-id: c835a0f19bae4a48572fee39d6db41fc7f34e2dc
This commit is contained in:
John-David Dalton
2013-08-14 23:29:24 -07:00
parent 381cd53551
commit ab66e77740

View File

@@ -993,7 +993,7 @@
(function() { (function() {
test('should not modify the resulting value from within `callback`', function() { test('should not modify the resulting value from within `callback`', function() {
var actual = _.filter([0], function(value, index, array) { var actual = _.filter([0], function(num, index, array) {
return (array[index] = 1); return (array[index] = 1);
}); });
@@ -1085,7 +1085,7 @@
}); });
test('should support the `thisArg` argument', function() { test('should support the `thisArg` argument', function() {
var actual = _.first(array, function(value, index) { var actual = _.first(array, function(num, index) {
return this[index] < 3; return this[index] < 3;
}, array); }, array);
@@ -1103,7 +1103,7 @@
ok(actual instanceof _); ok(actual instanceof _);
actual = _(array).first(function(value, index) { actual = _(array).first(function(num, index) {
return this[index] < 3; return this[index] < 3;
}, array); }, array);
@@ -1138,16 +1138,16 @@
}); });
test('should work with a `callback`', function() { test('should work with a `callback`', function() {
var actual = _.flatten(array, function(value) { var actual = _.flatten(array, function(object) {
return value.a; return object.a;
}); });
deepEqual(actual, [1, 2, 3]); deepEqual(actual, [1, 2, 3]);
}); });
test('should work with `isShallow` and `callback`', function() { test('should work with `isShallow` and `callback`', function() {
var actual = _.flatten(array, true, function(value) { var actual = _.flatten(array, true, function(object) {
return value.a; return object.a;
}); });
deepEqual(actual, [1, [2], 3]); deepEqual(actual, [1, [2], 3]);
@@ -1164,7 +1164,7 @@
}); });
test('should support the `thisArg` argument', function() { test('should support the `thisArg` argument', function() {
var actual = _.flatten(array, function(value, index) { var actual = _.flatten(array, function(object, index) {
return this[index].a; return this[index].a;
}, array); }, array);
@@ -1218,7 +1218,7 @@
test('`_.' + methodName + '` should support the `thisArg` argument', function() { test('`_.' + methodName + '` should support the `thisArg` argument', function() {
var actual; var actual;
function callback(value, index) { function callback(num, index) {
actual = this[index]; actual = this[index];
} }
@@ -1292,11 +1292,11 @@
var func = _[methodName]; var func = _[methodName];
test('iterates over the `length` property', function() { test('iterates over the `length` property', function() {
var keys = [], var object = { '0': 'zero', '1': 'one', 'length': 2 },
object = { '0': 'zero', '1': 'one', 'length': 2 }; props = [];
func(object, function(value, key) { keys.push(key); }); func(object, function(value, prop) { props.push(prop); });
deepEqual(keys.sort(), ['0', '1', 'length']); deepEqual(props.sort(), ['0', '1', 'length']);
}); });
}); });
@@ -1308,9 +1308,9 @@
var func = _[methodName]; var func = _[methodName];
test('`_.' + methodName + '` fixes the JScript [[DontEnum]] bug (test in IE < 9)', function() { test('`_.' + methodName + '` fixes the JScript [[DontEnum]] bug (test in IE < 9)', function() {
var keys = []; var props = [];
func(shadowedObject, function(value, key) { keys.push(key); }); func(shadowedObject, function(value, prop) { props.push(prop); });
deepEqual(keys.sort(), shadowedProps); deepEqual(props.sort(), shadowedProps);
}); });
test('`_.' + methodName + '` does not iterate over non-enumerable properties (test in IE < 9)', function() { test('`_.' + methodName + '` does not iterate over non-enumerable properties (test in IE < 9)', function() {
@@ -1330,15 +1330,14 @@
var message = 'non-enumerable properties on ' + builtin + '.prototype', var message = 'non-enumerable properties on ' + builtin + '.prototype',
props = []; props = [];
func(object, function(value, prop) { func(object, function(value, prop) { props.push(prop); });
props.push(prop);
});
if (/Error/.test(builtin)) { if (/Error/.test(builtin)) {
ok(_.every(['constructor', 'toString'], function(prop) { ok(_.every(['constructor', 'toString'], function(prop) {
return !_.contains(props, prop); return !_.contains(props, prop);
}), message); }), message);
} else { }
else {
deepEqual(props, [], message); deepEqual(props, [], message);
} }
}); });
@@ -1348,16 +1347,16 @@
function Foo() {} function Foo() {}
Foo.prototype.a = 1; Foo.prototype.a = 1;
var keys = []; var props = [];
function callback(value, key) { keys.push(key); } function callback(value, prop) { props.push(prop); }
func(Foo, callback); func(Foo, callback);
deepEqual(keys, []); deepEqual(props, []);
keys.length = 0; props.length = 0;
Foo.prototype = { 'a': 1 }; Foo.prototype = { 'a': 1 };
func(Foo, callback); func(Foo, callback);
deepEqual(keys, []); deepEqual(props, []);
}); });
}); });
@@ -1791,7 +1790,7 @@
}); });
test('should support the `thisArg` argument', function() { test('should support the `thisArg` argument', function() {
var actual = _.initial(array, function(value, index) { var actual = _.initial(array, function(num, index) {
return this[index] > 1; return this[index] > 1;
}, array); }, array);
@@ -2189,7 +2188,7 @@
}); });
test('should support the `thisArg` argument', function() { test('should support the `thisArg` argument', function() {
var actual = _.last(array, function(value, index) { var actual = _.last(array, function(num, index) {
return this[index] > 1; return this[index] > 1;
}, array); }, array);
@@ -2207,7 +2206,7 @@
ok(actual instanceof _); ok(actual instanceof _);
actual = _(array).last(function(value, index) { actual = _(array).last(function(num, index) {
return this[index] > 1; return this[index] > 1;
}, array); }, array);
@@ -2267,9 +2266,7 @@
(function() { (function() {
test('should return the correct result when iterating an object', function() { test('should return the correct result when iterating an object', function() {
var actual = _.map({ 'a': 1, 'b': 2, 'c': 3 }, function(value) { var actual = _.map({ 'a': 1, 'b': 2, 'c': 3 });
return value;
});
deepEqual(actual, [1, 2, 3]); deepEqual(actual, [1, 2, 3]);
}); });
@@ -2512,8 +2509,8 @@
}); });
test('should work with a `callback` argument', function() { test('should work with a `callback` argument', function() {
var actual = _.omit(object, function(value) { var actual = _.omit(object, function(num) {
return value == 1; return num === 1;
}); });
deepEqual(actual, expected); deepEqual(actual, expected);
@@ -2535,8 +2532,8 @@
}); });
test('should correct set the `this` binding', function() { test('should correct set the `this` binding', function() {
var actual = _.omit(object, function(value) { var actual = _.omit(object, function(num) {
return value == this.a; return num === this.a;
}, { 'a': 1 }); }, { 'a': 1 });
deepEqual(actual, expected); deepEqual(actual, expected);
@@ -2748,8 +2745,8 @@
}); });
test('should work with a `callback` argument', function() { test('should work with a `callback` argument', function() {
var actual = _.pick(object, function(value) { var actual = _.pick(object, function(num) {
return value == 2; return num === 2;
}); });
deepEqual(actual, expected); deepEqual(actual, expected);
@@ -2771,8 +2768,8 @@
}); });
test('should correct set the `this` binding', function() { test('should correct set the `this` binding', function() {
var actual = _.pick(object, function(value) { var actual = _.pick(object, function(num) {
return value == this.b; return num === this.b;
}, { 'b': 2 }); }, { 'b': 2 });
deepEqual(actual, expected); deepEqual(actual, expected);
@@ -2993,8 +2990,8 @@
test('should modify the array and return removed elements', function() { test('should modify the array and return removed elements', function() {
var array = [1, 2, 3]; var array = [1, 2, 3];
var actual = _.remove(array, function(value) { var actual = _.remove(array, function(num) {
return value < 3; return num < 3;
}); });
deepEqual(array, [3]); deepEqual(array, [3]);
@@ -3015,7 +3012,7 @@
test('should support the `thisArg` argument', function() { test('should support the `thisArg` argument', function() {
var array = [1, 2, 3]; var array = [1, 2, 3];
var actual = _.remove(array, function(value, index) { var actual = _.remove(array, function(num, index) {
return this[index] < 3; return this[index] < 3;
}, array); }, array);
@@ -3027,7 +3024,7 @@
delete array[1]; delete array[1];
delete array[3]; delete array[3];
_.remove(array, function(value) { return value === 1; }); _.remove(array, function(num) { return num === 1; });
equal(0 in array, false); equal(0 in array, false);
equal(2 in array, false); equal(2 in array, false);
}); });
@@ -3036,7 +3033,7 @@
var array = [1, 2, 3]; var array = [1, 2, 3];
delete array[1]; delete array[1];
_.remove(array, function(value) { return value == null; }); _.remove(array, function(num) { return num == null; });
deepEqual(array, [1, 3]); deepEqual(array, [1, 3]);
}); });
}()); }());
@@ -3104,7 +3101,7 @@
}); });
test('supports the `thisArg` argument', function() { test('supports the `thisArg` argument', function() {
var actual = _.rest(array, function(value, index) { var actual = _.rest(array, function(num, index) {
return this[index] < 3; return this[index] < 3;
}, array); }, array);