From 3c5932af75433122fa89af45864331b4581644ef Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 16 May 2014 08:01:47 -0700 Subject: [PATCH] Update Underscore tests and excuse tests for edge features from the Underscore build. --- test/underscore.html | 9 ++++++++- vendor/underscore/test/arrays.js | 8 ++++---- vendor/underscore/test/objects.js | 8 ++++---- vendor/underscore/test/utility.js | 6 +++--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/test/underscore.html b/test/underscore.html index 3a2180c80..13127378b 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -76,6 +76,11 @@ 'bindAll': [ 'throws an error for bindAll with no functions named' ], + 'memoize': [ + '{"bar":"BAR","foo":"FOO"}', + '"BAR"', + '"FOO"' + ], 'negate': true, 'partial': [ 'can partially apply with placeholders', @@ -135,7 +140,7 @@ delete QUnit.config.excused.Utility.times; delete QUnit.config.excused.Utility.uniqueId; } - // only excuse in non-Underscore builds + // only excuse for non-Underscore builds if (/\bunderscore\b/i.test(ui.buildPath)) { if (!ui.isModularize) { delete QUnit.config.excused.Functions.partial; @@ -149,7 +154,9 @@ delete QUnit.config.excused.Utility['_.escape']; delete QUnit.config.excused.Utility['_.unescape']; } + // only execuse edge features for the Underscore build else { + delete QUnit.config.excused.Functions.memoize; delete QUnit.config.excused.Functions.negate; delete QUnit.config.excused.Objects.pick; delete QUnit.config.excused.Utility.noop; diff --git a/vendor/underscore/test/arrays.js b/vendor/underscore/test/arrays.js index ae640f691..7370ffcc0 100644 --- a/vendor/underscore/test/arrays.js +++ b/vendor/underscore/test/arrays.js @@ -182,16 +182,16 @@ test('object', function() { var result = _.object(['moe', 'larry', 'curly'], [30, 40, 50]); var shouldBe = {moe: 30, larry: 40, curly: 50}; - ok(_.isEqual(result, shouldBe), 'two arrays zipped together into an object'); + deepEqual(result, shouldBe, 'two arrays zipped together into an object'); result = _.object([['one', 1], ['two', 2], ['three', 3]]); shouldBe = {one: 1, two: 2, three: 3}; - ok(_.isEqual(result, shouldBe), 'an array of pairs zipped together into an object'); + deepEqual(result, shouldBe, 'an array of pairs zipped together into an object'); var stooges = {moe: 30, larry: 40, curly: 50}; - ok(_.isEqual(_.object(_.pairs(stooges)), stooges), 'an object converted to pairs and back to an object'); + deepEqual(_.object(_.pairs(stooges)), stooges, 'an object converted to pairs and back to an object'); - ok(_.isEqual(_.object(null), {}), 'handles nulls'); + deepEqual(_.object(null), {}, 'handles nulls'); }); test('indexOf', function() { diff --git a/vendor/underscore/test/objects.js b/vendor/underscore/test/objects.js index c29cd6d4a..32a61e66c 100644 --- a/vendor/underscore/test/objects.js +++ b/vendor/underscore/test/objects.js @@ -27,7 +27,7 @@ test('invert', function() { var obj = {first: 'Moe', second: 'Larry', third: 'Curly'}; deepEqual(_.keys(_.invert(obj)), ['Moe', 'Larry', 'Curly'], 'can invert an object'); - ok(_.isEqual(_.invert(_.invert(obj)), obj), 'two inverts gets you back where you started'); + deepEqual(_.invert(_.invert(obj)), obj, 'two inverts gets you back where you started'); var obj = {length: 3}; ok(_.invert(obj)['3'] == 'length', 'can invert an object with "length"') @@ -35,7 +35,7 @@ test('functions', function() { var obj = {a : 'dash', b : _.map, c : (/yo/), d : _.reduce}; - ok(_.isEqual(['b', 'd'], _.functions(obj)), 'can grab the function names of any passed-in object'); + deepEqual(['b', 'd'], _.functions(obj), 'can grab the function names of any passed-in object'); var Animal = function(){}; Animal.prototype.run = function(){}; @@ -48,9 +48,9 @@ equal(_.extend({a: 'x'}, {a: 'b'}).a, 'b', 'properties in source override destination'); equal(_.extend({x: 'x'}, {a: 'b'}).x, 'x', "properties not in source don't get overriden"); result = _.extend({x: 'x'}, {a: 'a'}, {b: 'b'}); - ok(_.isEqual(result, {x: 'x', a: 'a', b: 'b'}), 'can extend from multiple source objects'); + deepEqual(result, {x: 'x', a: 'a', b: 'b'}, 'can extend from multiple source objects'); result = _.extend({x: 'x'}, {a: 'a', x: 2}, {a: 'b'}); - ok(_.isEqual(result, {x: 2, a: 'b'}), 'extending from multiple source objects last property trumps'); + deepEqual(result, {x: 2, a: 'b'}, 'extending from multiple source objects last property trumps'); result = _.extend({}, {a: void 0, b: null}); deepEqual(_.keys(result), ['a', 'b'], 'extend copies undefined values'); diff --git a/vendor/underscore/test/utility.js b/vendor/underscore/test/utility.js index bfa2a1110..37c90076d 100644 --- a/vendor/underscore/test/utility.js +++ b/vendor/underscore/test/utility.js @@ -67,13 +67,13 @@ test('times', function() { var vals = []; _.times(3, function (i) { vals.push(i); }); - ok(_.isEqual(vals, [0, 1, 2]), 'is 0 indexed'); + deepEqual(vals, [0, 1, 2], 'is 0 indexed'); // vals = []; _(3).times(function(i) { vals.push(i); }); - ok(_.isEqual(vals, [0, 1, 2]), 'works as a wrapper'); + deepEqual(vals, [0, 1, 2], 'works as a wrapper'); // collects return values - ok(_.isEqual([0, 1, 2], _.times(3, function(i) { return i; })), 'collects return values'); + deepEqual([0, 1, 2], _.times(3, function(i) { return i; }), 'collects return values'); deepEqual(_.times(0, _.identity), []); deepEqual(_.times(-1, _.identity), []);