WSL should have more tests of type checking failures
[WebKit-https.git] / JSTests / es6 / Promise_Promise.race.js
1 function test() {
2 var passed = false;
3 function asyncTestPassed() {
4     passed = true;
5 }
6
7 var fulfills = Promise.race([
8   new Promise(function(resolve)   { setTimeout(resolve,200,"foo"); }),
9   new Promise(function(_, reject) { setTimeout(reject, 300,"bar"); }),
10 ]);
11 var rejects = Promise.race([
12   new Promise(function(_, reject) { setTimeout(reject, 200,"baz"); }),
13   new Promise(function(resolve)   { setTimeout(resolve,300,"qux"); }),
14 ]);
15 var score = 0;
16 fulfills.then(function(result) { score += (result === "foo"); check(); });
17 rejects.catch(function(result) { score += (result === "baz"); check(); });
18
19 function check() {
20   if (score === 2) asyncTestPassed();
21 }
22       
23 drainMicrotasks();
24 return passed;
25 }
26
27 if (!test())
28     throw new Error("Test failed");
29