Cleanup large array tests.

This commit is contained in:
John-David Dalton
2014-03-16 01:01:09 -07:00
parent e13bf164ea
commit 7d4726d12e

View File

@@ -490,11 +490,8 @@
function message(methodName) { function message(methodName) {
return '`_.' + methodName + '` should avoid overwritten native methods'; return '`_.' + methodName + '` should avoid overwritten native methods';
} }
var object = { 'a': true }; var object = { 'a': true },
largeArray = _.times(LARGE_ARRAY_SIZE, _.constant(object));
var largeArray = _.times(LARGE_ARRAY_SIZE, function() {
return object;
});
if (lodashBizarro) { if (lodashBizarro) {
try { try {
@@ -626,7 +623,6 @@
this.a = 1; this.a = 1;
this.c = 3; this.c = 3;
} }
Foo.prototype.b = 2; Foo.prototype.b = 2;
deepEqual(_.assign({}, new Foo), { 'a': 1, 'c': 3 }); deepEqual(_.assign({}, new Foo), { 'a': 1, 'c': 3 });
}); });
@@ -893,7 +889,6 @@
this._b = 2; this._b = 2;
this.a = function() { return this._a; }; this.a = function() { return this._a; };
} }
Foo.prototype.b = function() { return this._b; }; Foo.prototype.b = function() { return this._b; };
var object = new Foo; var object = new Foo;
@@ -2026,7 +2021,6 @@
this.a = 1; this.a = 1;
this.c = 3; this.c = 3;
} }
Foo.prototype.b = 2; Foo.prototype.b = 2;
deepEqual(_.defaults({ 'c': 2 }, new Foo), { 'a': 1, 'c': 2 }); deepEqual(_.defaults({ 'c': 2 }, new Foo), { 'a': 1, 'c': 2 });
}); });
@@ -2204,11 +2198,8 @@
test('should work with large arrays of objects', 1, function() { test('should work with large arrays of objects', 1, function() {
var object1 = {}, var object1 = {},
object2 = {}; object2 = {},
largeArray = [object1].concat(_.times(LARGE_ARRAY_SIZE, _.constant(object2)));
var largeArray = [object1].concat(_.times(LARGE_ARRAY_SIZE, function() {
return object2;
}));
deepEqual(_.difference(largeArray, [object2]), [object1]); deepEqual(_.difference(largeArray, [object2]), [object1]);
}); });
@@ -3251,7 +3242,6 @@
this.a = _.identity; this.a = _.identity;
this.b = 'b' this.b = 'b'
} }
Foo.prototype.c = noop; Foo.prototype.c = noop;
deepEqual(_.functions(new Foo), ['a', 'c']); deepEqual(_.functions(new Foo), ['a', 'c']);
}); });
@@ -3477,6 +3467,8 @@
QUnit.module('custom `_.indexOf` methods'); QUnit.module('custom `_.indexOf` methods');
(function() { (function() {
function Foo() {}
function custom(array, value, fromIndex) { function custom(array, value, fromIndex) {
var index = (fromIndex || 0) - 1, var index = (fromIndex || 0) - 1,
length = array.length; length = array.length;
@@ -3489,9 +3481,6 @@
} }
return -1; return -1;
} }
function Foo() {}
var array = [1, new Foo, 3, new Foo], var array = [1, new Foo, 3, new Foo],
indexOf = _.indexOf; indexOf = _.indexOf;
@@ -3655,11 +3644,8 @@
test('should work with large arrays of objects', 1, function() { test('should work with large arrays of objects', 1, function() {
var object = {}, var object = {},
expected = [object]; expected = [object],
largeArray = _.times(LARGE_ARRAY_SIZE, _.constant(object));
var largeArray = _.times(LARGE_ARRAY_SIZE, function() {
return object;
});
deepEqual(_.intersection(expected, largeArray), expected); deepEqual(_.intersection(expected, largeArray), expected);
}); });
@@ -4198,9 +4184,7 @@
}); });
test('should perform comparisons between object instances', 4, function() { test('should perform comparisons between object instances', 4, function() {
function Foo() { function Foo() { this.value = 1; }
this.value = 1;
}
Foo.prototype.value = 1; Foo.prototype.value = 1;
function Bar() { function Bar() {
@@ -8652,7 +8636,6 @@
this.b = 2; this.b = 2;
this.c = 3; this.c = 3;
} }
var actual = _.transform(new Foo, function(result, value, key) { var actual = _.transform(new Foo, function(result, value, key) {
result[key] = value * value; result[key] = value * value;
}); });
@@ -8892,6 +8875,7 @@
_.times(count, function() { _.times(count, function() {
push.apply(array, expected); push.apply(array, expected);
}); });
deepEqual(_.uniq(array), expected); deepEqual(_.uniq(array), expected);
}); });