Increase code coverage when testing AMD modules.

This commit is contained in:
John-David Dalton
2014-04-13 16:12:08 -07:00
parent e306959ebe
commit 7d7a34c733

View File

@@ -498,12 +498,13 @@
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': 1 },
otherObject = { 'b': 2 },
largeArray = _.times(largeArraySize, _.constant(object)); largeArray = _.times(largeArraySize, _.constant(object));
if (lodashBizarro) { if (lodashBizarro) {
try { try {
actual = [lodashBizarro.isArray([]), lodashBizarro.isArray({ 'length': 0 })]; var actual = [lodashBizarro.isArray([]), lodashBizarro.isArray({ 'length': 0 })];
} catch(e) { } catch(e) {
actual = null; actual = null;
} }
@@ -525,7 +526,7 @@
deepEqual(actual[1], {}, message('Object.create')); deepEqual(actual[1], {}, message('Object.create'));
try { try {
var actual = lodashBizarro.bind(function() { return this.a; }, object); actual = lodashBizarro.bind(function() { return this.a; }, object);
} catch(e) { } catch(e) {
actual = null; actual = null;
} }
@@ -547,14 +548,14 @@
try { try {
actual = [ actual = [
lodashBizarro.difference([object], largeArray), lodashBizarro.difference([object, otherObject], largeArray),
lodashBizarro.intersection(largeArray, [object]), lodashBizarro.intersection(largeArray, [object]),
lodashBizarro.uniq(largeArray) lodashBizarro.uniq(largeArray)
]; ];
} catch(e) { } catch(e) {
actual = null; actual = null;
} }
deepEqual(actual, [[], [object], [object]], message('Set')); deepEqual(actual, [[otherObject], [object], [object]], message('Set'));
try { try {
actual = lodashBizarro.contains('abc', 'c'); actual = lodashBizarro.contains('abc', 'c');
@@ -2326,9 +2327,9 @@
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(largeArraySize, _.constant(object2))); largeArray = _.times(largeArraySize, _.constant(object1));
deepEqual(_.difference(largeArray, [object2]), [object1]); deepEqual(_.difference([object1, object2], largeArray), [object2]);
}); });
test('should ignore individual secondary arguments', 1, function() { test('should ignore individual secondary arguments', 1, function() {
@@ -3860,21 +3861,17 @@
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],
largeArray = _.times(largeArraySize, _.constant(object)); largeArray = _.times(largeArraySize, _.constant(object));
deepEqual(_.intersection(expected, largeArray), expected); deepEqual(_.intersection([object], largeArray), [object]);
}); });
test('should work with large arrays of objects', 2, function() { test('should work with large arrays of objects', 2, function() {
var object = {}, var object = {},
expected = [object],
largeArray = _.times(largeArraySize, _.constant(object)); largeArray = _.times(largeArraySize, _.constant(object));
deepEqual(_.intersection(expected, largeArray), expected); deepEqual(_.intersection([object], largeArray), [object]);
deepEqual(_.intersection(_.range(largeArraySize), null, [1]), [1]);
expected = [1];
deepEqual(_.intersection(_.range(largeArraySize), null, expected), expected);
}); });
test('should return a wrapped value when chaining', 2, function() { test('should return a wrapped value when chaining', 2, function() {
@@ -4677,13 +4674,13 @@
function Foo() { this.a = 1; } function Foo() { this.a = 1; }
Foo.prototype.constructor = null; Foo.prototype.constructor = null;
var other = { 'a': 1 }; var otherObject = { 'a': 1 };
strictEqual(_.isEqual(new Foo, other), false); strictEqual(_.isEqual(new Foo, otherObject), false);
if (create) { if (create) {
var object = Object.create(null); var object = Object.create(null);
object.a = 1; object.a = 1;
strictEqual(_.isEqual(object, other), true); strictEqual(_.isEqual(object, otherObject), true);
} }
else { else {
skipTest(); skipTest();