Update Underscore tests and excuse tests for edge features from the Underscore build.

This commit is contained in:
John-David Dalton
2014-05-16 08:01:47 -07:00
parent f40a7d47f5
commit 3c5932af75
4 changed files with 19 additions and 12 deletions

View File

@@ -76,6 +76,11 @@
'bindAll': [ 'bindAll': [
'throws an error for bindAll with no functions named' 'throws an error for bindAll with no functions named'
], ],
'memoize': [
'{"bar":"BAR","foo":"FOO"}',
'"BAR"',
'"FOO"'
],
'negate': true, 'negate': true,
'partial': [ 'partial': [
'can partially apply with placeholders', 'can partially apply with placeholders',
@@ -135,7 +140,7 @@
delete QUnit.config.excused.Utility.times; delete QUnit.config.excused.Utility.times;
delete QUnit.config.excused.Utility.uniqueId; 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 (/\bunderscore\b/i.test(ui.buildPath)) {
if (!ui.isModularize) { if (!ui.isModularize) {
delete QUnit.config.excused.Functions.partial; delete QUnit.config.excused.Functions.partial;
@@ -149,7 +154,9 @@
delete QUnit.config.excused.Utility['_.escape']; delete QUnit.config.excused.Utility['_.escape'];
delete QUnit.config.excused.Utility['_.unescape']; delete QUnit.config.excused.Utility['_.unescape'];
} }
// only execuse edge features for the Underscore build
else { else {
delete QUnit.config.excused.Functions.memoize;
delete QUnit.config.excused.Functions.negate; delete QUnit.config.excused.Functions.negate;
delete QUnit.config.excused.Objects.pick; delete QUnit.config.excused.Objects.pick;
delete QUnit.config.excused.Utility.noop; delete QUnit.config.excused.Utility.noop;

View File

@@ -182,16 +182,16 @@
test('object', function() { test('object', function() {
var result = _.object(['moe', 'larry', 'curly'], [30, 40, 50]); var result = _.object(['moe', 'larry', 'curly'], [30, 40, 50]);
var shouldBe = {moe: 30, larry: 40, curly: 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]]); result = _.object([['one', 1], ['two', 2], ['three', 3]]);
shouldBe = {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}; 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() { test('indexOf', function() {

View File

@@ -27,7 +27,7 @@
test('invert', function() { test('invert', function() {
var obj = {first: 'Moe', second: 'Larry', third: 'Curly'}; var obj = {first: 'Moe', second: 'Larry', third: 'Curly'};
deepEqual(_.keys(_.invert(obj)), ['Moe', 'Larry', 'Curly'], 'can invert an object'); 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}; var obj = {length: 3};
ok(_.invert(obj)['3'] == 'length', 'can invert an object with "length"') ok(_.invert(obj)['3'] == 'length', 'can invert an object with "length"')
@@ -35,7 +35,7 @@
test('functions', function() { test('functions', function() {
var obj = {a : 'dash', b : _.map, c : (/yo/), d : _.reduce}; 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(){}; var Animal = function(){};
Animal.prototype.run = function(){}; Animal.prototype.run = function(){};
@@ -48,9 +48,9 @@
equal(_.extend({a: 'x'}, {a: 'b'}).a, 'b', 'properties in source override destination'); 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"); equal(_.extend({x: 'x'}, {a: 'b'}).x, 'x', "properties not in source don't get overriden");
result = _.extend({x: 'x'}, {a: 'a'}, {b: 'b'}); 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'}); 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}); result = _.extend({}, {a: void 0, b: null});
deepEqual(_.keys(result), ['a', 'b'], 'extend copies undefined values'); deepEqual(_.keys(result), ['a', 'b'], 'extend copies undefined values');

View File

@@ -67,13 +67,13 @@
test('times', function() { test('times', function() {
var vals = []; var vals = [];
_.times(3, function (i) { vals.push(i); }); _.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 = []; vals = [];
_(3).times(function(i) { vals.push(i); }); _(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 // 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(0, _.identity), []);
deepEqual(_.times(-1, _.identity), []); deepEqual(_.times(-1, _.identity), []);