|
|
@ -6,11 +6,12 @@ |
|
|
|
|
|
|
|
function testBatch() { |
|
|
|
var timeouts = [100, 80, 20, 500, 50, 30, 200, 300]; |
|
|
|
console.info(timeouts); |
|
|
|
var tasks = timeouts.map(function(timeout, i) { |
|
|
|
return function() { |
|
|
|
return promiseTimeout(timeout).then(function() { |
|
|
|
console.log("task:", i, timeouts[i]); |
|
|
|
return i; |
|
|
|
//console.log("task:", i, timeouts[i]);
|
|
|
|
return i + ":" + timeouts[i]; |
|
|
|
}); |
|
|
|
}; |
|
|
|
}); |
|
|
@ -71,7 +72,7 @@ |
|
|
|
} |
|
|
|
return null; |
|
|
|
}) |
|
|
|
.then(function(results) { |
|
|
|
.then(function(/*results*/) { |
|
|
|
var e = new Error("should not pass sync exception!"); |
|
|
|
e.FAIL = true; |
|
|
|
throw e; |
|
|
@ -90,7 +91,7 @@ |
|
|
|
} |
|
|
|
|
|
|
|
function promiseTimeout(timeout) { |
|
|
|
return new Promise(function(resolve, reject) { |
|
|
|
return new Promise(function(resolve) { |
|
|
|
setTimeout(resolve, timeout); |
|
|
|
}); |
|
|
|
} |
|
|
@ -99,7 +100,7 @@ |
|
|
|
.then(function() { |
|
|
|
console.info("PROBABLY PASSED"); |
|
|
|
console.info( |
|
|
|
"We tested what could be tested without knowing Passed what could be tested Do the results make sense?" |
|
|
|
"We tested what could be tested. Do the results make sense?" |
|
|
|
); |
|
|
|
}) |
|
|
|
.catch(function(e) { |
|
|
|