"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/underscore/test/functions.js" between
lodash-4.0.0.tar.gz and lodash-4.17.21.tar.gz

About: lodash is a modern JavaScript utility library delivering modularity, performance, & extras. Tagged version.

functions.js  (lodash-4.0.0):functions.js  (lodash-4.17.21)
skipping to change at line 183 skipping to change at line 183
assert.notStrictEqual(myObj, void 0, 'object is created if second argument u sed as key'); assert.notStrictEqual(myObj, void 0, 'object is created if second argument u sed as key');
assert.strictEqual(myObj, myObjAlias, 'object is cached if second argument u sed as key'); assert.strictEqual(myObj, myObjAlias, 'object is cached if second argument u sed as key');
assert.strictEqual(myObj.value, 'a', 'object is not modified if second argum ent used as key'); assert.strictEqual(myObj.value, 'a', 'object is not modified if second argum ent used as key');
}); });
QUnit.test('delay', function(assert) { QUnit.test('delay', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async(); var done = assert.async();
var delayed = false; var delayed = false;
_.delay(function(){ delayed = true; }, 100); _.delay(function(){ delayed = true; }, 100);
setTimeout(function(){ assert.ok(!delayed, "didn't delay the function quite yet"); }, 50); setTimeout(function(){ assert.notOk(delayed, "didn't delay the function quit e yet"); }, 50);
setTimeout(function(){ assert.ok(delayed, 'delayed the function'); done(); } , 150); setTimeout(function(){ assert.ok(delayed, 'delayed the function'); done(); } , 150);
}); });
QUnit.test('defer', function(assert) { QUnit.test('defer', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async(); var done = assert.async();
var deferred = false; var deferred = false;
_.defer(function(bool){ deferred = bool; }, true); _.defer(function(bool){ deferred = bool; }, true);
_.delay(function(){ assert.ok(deferred, 'deferred the function'); done(); }, 50); _.delay(function(){ assert.ok(deferred, 'deferred the function'); done(); }, 50);
}); });
skipping to change at line 478 skipping to change at line 478
var done = assert.async(); var done = assert.async();
var counter = 0; var counter = 0;
var incr = function(){ counter++; }; var incr = function(){ counter++; };
var debouncedIncr = _.debounce(incr, 32); var debouncedIncr = _.debounce(incr, 32);
debouncedIncr(); debouncedIncr();
debouncedIncr.cancel(); debouncedIncr.cancel();
_.delay(function(){ assert.equal(counter, 0, 'incr was not called'); done(); }, 96); _.delay(function(){ assert.equal(counter, 0, 'incr was not called'); done(); }, 96);
}); });
QUnit.test('debounce asap', function(assert) { QUnit.test('debounce asap', function(assert) {
assert.expect(4); assert.expect(6);
var done = assert.async(); var done = assert.async();
var a, b; var a, b, c;
var counter = 0; var counter = 0;
var incr = function(){ return ++counter; }; var incr = function(){ return ++counter; };
var debouncedIncr = _.debounce(incr, 64, true); var debouncedIncr = _.debounce(incr, 64, true);
a = debouncedIncr(); a = debouncedIncr();
b = debouncedIncr(); b = debouncedIncr();
assert.equal(a, 1); assert.equal(a, 1);
assert.equal(b, 1); assert.equal(b, 1);
assert.equal(counter, 1, 'incr was called immediately'); assert.equal(counter, 1, 'incr was called immediately');
_.delay(debouncedIncr, 16); _.delay(debouncedIncr, 16);
_.delay(debouncedIncr, 32); _.delay(debouncedIncr, 32);
_.delay(debouncedIncr, 48); _.delay(debouncedIncr, 48);
_.delay(function(){ assert.equal(counter, 1, 'incr was debounced'); done(); _.delay(function(){
}, 128); assert.equal(counter, 1, 'incr was debounced');
c = debouncedIncr();
assert.equal(c, 2);
assert.equal(counter, 2, 'incr was called again');
done();
}, 128);
}); });
QUnit.test('debounce asap cancel', function(assert) { QUnit.test('debounce asap cancel', function(assert) {
assert.expect(4); assert.expect(4);
var done = assert.async(); var done = assert.async();
var a, b; var a, b;
var counter = 0; var counter = 0;
var incr = function(){ return ++counter; }; var incr = function(){ return ++counter; };
var debouncedIncr = _.debounce(incr, 64, true); var debouncedIncr = _.debounce(incr, 64, true);
a = debouncedIncr(); a = debouncedIncr();
skipping to change at line 691 skipping to change at line 697
function fn() { function fn() {
return arguments; return arguments;
} }
_.each([_.iteratee(fn), _.iteratee(fn, {})], function(cb) { _.each([_.iteratee(fn), _.iteratee(fn, {})], function(cb) {
assert.equal(cb().length, 0); assert.equal(cb().length, 0);
assert.deepEqual(_.toArray(cb(1, 2, 3)), _.range(1, 4)); assert.deepEqual(_.toArray(cb(1, 2, 3)), _.range(1, 4));
assert.deepEqual(_.toArray(cb(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), _.range(1, 11)); assert.deepEqual(_.toArray(cb(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), _.range(1, 11));
}); });
// Test custom iteratee
var builtinIteratee = _.iteratee;
_.iteratee = function(value) {
// RegEx values return a function that returns the number of matches
if (_.isRegExp(value)) return function(obj) {
return (obj.match(value) || []).length;
};
return value;
};
var collection = ['foo', 'bar', 'bbiz'];
// Test all methods that claim to be transformed through `_.iteratee`
assert.deepEqual(_.countBy(collection, /b/g), {0: 1, 1: 1, 2: 1});
assert.equal(_.every(collection, /b/g), false);
assert.deepEqual(_.filter(collection, /b/g), ['bar', 'bbiz']);
assert.equal(_.find(collection, /b/g), 'bar');
assert.equal(_.findIndex(collection, /b/g), 1);
assert.equal(_.findKey(collection, /b/g), 1);
assert.equal(_.findLastIndex(collection, /b/g), 2);
assert.deepEqual(_.groupBy(collection, /b/g), {0: ['foo'], 1: ['bar'], 2: ['
bbiz']});
assert.deepEqual(_.indexBy(collection, /b/g), {0: 'foo', 1: 'bar', 2: 'bbiz'
});
assert.deepEqual(_.map(collection, /b/g), [0, 1, 2]);
assert.equal(_.max(collection, /b/g), 'bbiz');
assert.equal(_.min(collection, /b/g), 'foo');
assert.deepEqual(_.partition(collection, /b/g), [['bar', 'bbiz'], ['foo']]);
assert.deepEqual(_.reject(collection, /b/g), ['foo']);
assert.equal(_.some(collection, /b/g), true);
assert.deepEqual(_.sortBy(collection, /b/g), ['foo', 'bar', 'bbiz']);
assert.equal(_.sortedIndex(collection, 'blah', /b/g), 1);
assert.deepEqual(_.uniq(collection, /b/g), ['foo', 'bar', 'bbiz']);
var objCollection = {a: 'foo', b: 'bar', c: 'bbiz'};
assert.deepEqual(_.mapObject(objCollection, /b/g), {a: 0, b: 1, c: 2});
// Restore the builtin iteratee
_.iteratee = builtinIteratee;
}); });
QUnit.test('restArgs', function(assert) { QUnit.test('restArgs', function(assert) {
assert.expect(10); assert.expect(10);
_.restArgs(function(a, args) { _.restArgs(function(a, args) {
assert.strictEqual(a, 1); assert.strictEqual(a, 1);
assert.deepEqual(args, [2, 3], 'collects rest arguments into an array'); assert.deepEqual(args, [2, 3], 'collects rest arguments into an array');
})(1, 2, 3); })(1, 2, 3);
_.restArgs(function(a, args) { _.restArgs(function(a, args) {
 End of changes. 5 change blocks. 
5 lines changed or deleted 49 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)