Update vendor/benchmark.js and vendor/underscore tests.

Former-commit-id: 28d47ac7efb1af2d23a749ea50178c09edfe62bd
This commit is contained in:
John-David Dalton
2013-08-03 21:33:58 -07:00
parent 76dcd7d96e
commit a9bf6a0e3b
4 changed files with 25 additions and 17 deletions

View File

@@ -107,6 +107,8 @@ $(document).ready(function() {
equal(_(stooges).intersection(leaders).join(''), 'moe', 'can perform an OO-style intersection');
var result = (function(){ return _.intersection(arguments, leaders); })('moe', 'curly', 'larry');
equal(result.join(''), 'moe', 'works on an arguments object');
var theSixStooges = ['moe', 'moe', 'curly', 'curly', 'larry', 'larry'];
equal(_.intersection(theSixStooges, leaders).join(''), 'moe', 'returns a duplicate-free array');
});
test("union", function() {

View File

@@ -274,6 +274,12 @@ $(document).ready(function() {
deepEqual(result, {a: 1, b: 2});
result = _.findWhere(list, {b: 4});
deepEqual(result, {a: 1, b: 4});
result = _.findWhere(list, {c:1})
ok(_.isUndefined(result), "undefined when not found");
result = _.findWhere([], {c:1});
ok(_.isUndefined(result), "undefined when searching empty list");
});
test('max', function() {

View File

@@ -159,14 +159,14 @@ $(document).ready(function() {
asyncTest("throttle repeatedly with results", 6, function() {
var counter = 0;
var incr = function(){ return ++counter; };
var throttledIncr = _.throttle(incr, 64);
var throttledIncr = _.throttle(incr, 100);
var results = [];
var saveResult = function() { results.push(throttledIncr()); };
saveResult(); saveResult();
_.delay(saveResult, 32);
_.delay(saveResult, 80);
_.delay(saveResult, 96);
_.delay(saveResult, 144);
_.delay(saveResult, 50);
_.delay(saveResult, 150);
_.delay(saveResult, 160);
_.delay(saveResult, 230);
_.delay(function() {
equal(results[0], 1, "incr was called once");
equal(results[1], 1, "incr was throttled");
@@ -175,7 +175,7 @@ $(document).ready(function() {
equal(results[4], 2, "incr was throttled");
equal(results[5], 3, "incr was called trailing");
start();
}, 192);
}, 300);
});
asyncTest("throttle triggers trailing call when invoked repeatedly", 2, function() {