| function asyncTestPassed() { |
| var p1 = new Promise(function(resolve, reject) { resolve("foo"); }); |
| var p2 = new Promise(function(resolve, reject) { reject("quux"); }); |
| function thenFn(result) { score += (result === "foo"); check(); } |
| function catchFn(result) { score += (result === "quux"); check(); } |
| function shouldNotRun(result) { score = -Infinity; } |
| p1.then(thenFn, shouldNotRun); |
| p2.then(shouldNotRun, catchFn); |
| // Promise.prototype.then() should return a new Promise |
| score += p1.then() !== p1; |
| if (score === 4) asyncTestPassed(); |
| throw new Error("Test failed"); |