mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Update vendors.
This commit is contained in:
6
vendor/underscore/test/arrays.js
vendored
6
vendor/underscore/test/arrays.js
vendored
@@ -344,6 +344,9 @@
|
||||
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN), 2, 'Expected [1, 2, NaN] to contain NaN');
|
||||
strictEqual(_.indexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
|
||||
|
||||
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN, 1), 2, 'startIndex does not affect result');
|
||||
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN, -2), 2, 'startIndex does not affect result');
|
||||
|
||||
(function() {
|
||||
strictEqual(_.indexOf(arguments, NaN), 2, 'Expected arguments [1, 2, NaN] to contain NaN');
|
||||
}(1, 2, NaN, NaN));
|
||||
@@ -418,6 +421,9 @@
|
||||
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN), 3, 'Expected [1, 2, NaN] to contain NaN');
|
||||
strictEqual(_.lastIndexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
|
||||
|
||||
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN, 2), 2, 'fromIndex does not affect result');
|
||||
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN, -2), 2, 'fromIndex does not affect result');
|
||||
|
||||
(function() {
|
||||
strictEqual(_.lastIndexOf(arguments, NaN), 3, 'Expected arguments [1, 2, NaN] to contain NaN');
|
||||
}(1, 2, NaN, NaN));
|
||||
|
||||
22
vendor/underscore/test/collections.js
vendored
22
vendor/underscore/test/collections.js
vendored
@@ -23,6 +23,13 @@
|
||||
deepEqual(answers, ['one', 'two', 'three'], 'iterating over objects works, and ignores the object prototype.');
|
||||
delete obj.constructor.prototype.four;
|
||||
|
||||
// ensure the each function is JITed
|
||||
_(1000).times(function() { _.each([], function(){}); });
|
||||
var count = 0;
|
||||
obj = {1 : 'foo', 2 : 'bar', 3 : 'baz'};
|
||||
_.each(obj, function(value, key){ count++; });
|
||||
equal(count, 3, 'the fun should be called only 3 times');
|
||||
|
||||
var answer = null;
|
||||
_.each([1, 2, 3], function(num, index, arr){ if (_.include(arr, num)) answer = true; });
|
||||
ok(answer, 'can reference the original collection from inside the iterator');
|
||||
@@ -420,12 +427,14 @@
|
||||
strictEqual(_.includes, _.contains, 'alias for includes');
|
||||
|
||||
var numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
|
||||
strictEqual(_.includes(numbers, 1, 1), true);
|
||||
strictEqual(_.includes(numbers, 1, -1), false);
|
||||
strictEqual(_.includes(numbers, 1, -2), false);
|
||||
strictEqual(_.includes(numbers, 1, -3), true);
|
||||
strictEqual(_.includes(numbers, 1, 6), true);
|
||||
strictEqual(_.includes(numbers, 1, 7), false);
|
||||
strictEqual(_.includes(numbers, 1, 1), true, 'contains takes a fromIndex');
|
||||
strictEqual(_.includes(numbers, 1, -1), false, 'contains takes a fromIndex');
|
||||
strictEqual(_.includes(numbers, 1, -2), false, 'contains takes a fromIndex');
|
||||
strictEqual(_.includes(numbers, 1, -3), true, 'contains takes a fromIndex');
|
||||
strictEqual(_.includes(numbers, 1, 6), true, 'contains takes a fromIndex');
|
||||
strictEqual(_.includes(numbers, 1, 7), false, 'contains takes a fromIndex');
|
||||
|
||||
ok(_.every([1, 2, 3], _.partial(_.contains, numbers)), 'fromIndex is guarded');
|
||||
});
|
||||
|
||||
test('includes with NaN', function() {
|
||||
@@ -789,6 +798,7 @@
|
||||
equal(_.size(new String('hello')), 5, 'can compute the size of string object');
|
||||
|
||||
equal(_.size(null), 0, 'handles nulls');
|
||||
equal(_.size(0), 0, 'handles numbers');
|
||||
});
|
||||
|
||||
test('partition', function() {
|
||||
|
||||
26
vendor/underscore/test/objects.js
vendored
26
vendor/underscore/test/objects.js
vendored
@@ -282,6 +282,32 @@
|
||||
equal(_.clone(null), null, 'non objects should not be changed by clone');
|
||||
});
|
||||
|
||||
test('create', function() {
|
||||
var Parent = function() {};
|
||||
Parent.prototype = {foo: function() {}, bar: 2};
|
||||
|
||||
_.each(['foo', null, undefined, 1], function(val) {
|
||||
deepEqual(_.create(val), {}, 'should return empty object when a non-object is provided');
|
||||
});
|
||||
|
||||
ok(_.create([]) instanceof Array, 'should return new instance of array when array is provided');
|
||||
|
||||
var Child = function() {};
|
||||
Child.prototype = _.create(Parent.prototype);
|
||||
ok(new Child instanceof Parent, 'object should inherit prototype');
|
||||
|
||||
var func = function() {};
|
||||
Child.prototype = _.create(Parent.prototype, {func: func});
|
||||
strictEqual(Child.prototype.func, func, 'properties should be added to object');
|
||||
|
||||
Child.prototype = _.create(Parent.prototype, {constructor: Child});
|
||||
strictEqual(Child.prototype.constructor, Child);
|
||||
|
||||
Child.prototype.foo = 'foo';
|
||||
var created = _.create(Child.prototype, new Child);
|
||||
ok(!created.hasOwnProperty('foo'), 'should only add own properties');
|
||||
});
|
||||
|
||||
test('isEqual', function() {
|
||||
function First() {
|
||||
this.value = 1;
|
||||
|
||||
Reference in New Issue
Block a user