mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Update Underscore tests and excuse tests for edge features from the Underscore build.
This commit is contained in:
8
vendor/underscore/test/arrays.js
vendored
8
vendor/underscore/test/arrays.js
vendored
@@ -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() {
|
||||
|
||||
8
vendor/underscore/test/objects.js
vendored
8
vendor/underscore/test/objects.js
vendored
@@ -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');
|
||||
|
||||
|
||||
6
vendor/underscore/test/utility.js
vendored
6
vendor/underscore/test/utility.js
vendored
@@ -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), []);
|
||||
|
||||
Reference in New Issue
Block a user