mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Update vendor/underscore to v1.5.1 and update copyrights and tested environments.
Former-commit-id: 3bdfb1de97d08d05199f5f97c9c3145d7068e7fd
This commit is contained in:
14
vendor/underscore/test/arrays.js
vendored
14
vendor/underscore/test/arrays.js
vendored
@@ -134,19 +134,17 @@ $(document).ready(function() {
|
||||
var names = ['moe', 'larry', 'curly'], ages = [30, 40, 50], leaders = [true];
|
||||
var stooges = _.zip(names, ages, leaders);
|
||||
equal(String(stooges), 'moe,30,true,larry,40,,curly,50,', 'zipped together arrays of different lengths');
|
||||
});
|
||||
|
||||
test('unzip', function() {
|
||||
var stoogesUnzipped = _.unzip(['moe',30, 'stooge 1'],['larry',40, 'stooge 2'],['curly',50, 'stooge 3']);
|
||||
deepEqual(stoogesUnzipped, [['moe','larry','curly'],[30,40,50], ['stooge 1', 'stooge 2', 'stooge 3']], 'unzipped pairs');
|
||||
stooges = _.zip(['moe',30, 'stooge 1'],['larry',40, 'stooge 2'],['curly',50, 'stooge 3']);
|
||||
deepEqual(stooges, [['moe','larry','curly'],[30,40,50], ['stooge 1', 'stooge 2', 'stooge 3']], 'zipped pairs');
|
||||
|
||||
// In the case of difference lengths of the tuples undefineds
|
||||
// should be used as placeholder
|
||||
stoogesUnzipped = _.unzip(['moe',30],['larry',40],['curly',50, 'extra data']);
|
||||
deepEqual(stoogesUnzipped, [['moe','larry','curly'],[30,40,50], [undefined, undefined, 'extra data']], 'unzipped pairs');
|
||||
stooges = _.zip(['moe',30],['larry',40],['curly',50, 'extra data']);
|
||||
deepEqual(stooges, [['moe','larry','curly'],[30,40,50], [undefined, undefined, 'extra data']], 'zipped pairs with empties');
|
||||
|
||||
var emptyUnzipped = _.unzip([]);
|
||||
deepEqual(emptyUnzipped, [], 'unzipped empty');
|
||||
var empty = _.zip([]);
|
||||
deepEqual(empty, [], 'unzipped empty');
|
||||
});
|
||||
|
||||
test('object', function() {
|
||||
|
||||
50
vendor/underscore/test/functions.js
vendored
50
vendor/underscore/test/functions.js
vendored
@@ -142,6 +142,20 @@ $(document).ready(function() {
|
||||
_.delay(function(){ equal(counter, 2, "incr was called twice"); start(); }, 64);
|
||||
});
|
||||
|
||||
asyncTest("more throttling", 3, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 30);
|
||||
throttledIncr(); throttledIncr();
|
||||
ok(counter == 1);
|
||||
_.delay(function(){
|
||||
ok(counter == 2);
|
||||
throttledIncr();
|
||||
ok(counter == 3);
|
||||
start();
|
||||
}, 85);
|
||||
});
|
||||
|
||||
asyncTest("throttle repeatedly with results", 6, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ return ++counter; };
|
||||
@@ -197,6 +211,42 @@ $(document).ready(function() {
|
||||
}, 96);
|
||||
});
|
||||
|
||||
asyncTest("more throttle does not trigger leading call when leading is set to false", 3, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 100, {leading: false});
|
||||
|
||||
throttledIncr();
|
||||
_.delay(throttledIncr, 50);
|
||||
_.delay(throttledIncr, 60);
|
||||
_.delay(throttledIncr, 200);
|
||||
ok(counter === 0);
|
||||
|
||||
_.delay(function() {
|
||||
ok(counter == 1);
|
||||
}, 250);
|
||||
|
||||
_.delay(function() {
|
||||
ok(counter == 2);
|
||||
start();
|
||||
}, 350);
|
||||
});
|
||||
|
||||
asyncTest("one more throttle with leading: false test", 2, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 100, {leading: false});
|
||||
|
||||
var time = new Date;
|
||||
while (new Date - time < 350) throttledIncr();
|
||||
ok(counter === 3);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 4);
|
||||
start();
|
||||
}, 200);
|
||||
});
|
||||
|
||||
asyncTest("throttle does not trigger trailing call when trailing is set to false", 4, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
|
||||
Reference in New Issue
Block a user