Debian Codegraph @

js/src/tests/non262/Promise/promise-all.js

raw
1 // |reftest| skip-if(!xulRuntime.shell) -- needs drainJobQueue
2
3 let results = [];
4
5 let p1 = new Promise(res=>res('result'))
6 .then(val=>{results.push('then ' + val); return 'first then rval';})
7 .then(val=>{results.push('chained then with val: ' + val); return 'p1 then, then'});
8
9 let p2 = new Promise((res, rej)=>rej('rejection'))
10 .catch(val=> {results.push('catch ' + val); return results.length;})
11 .then(val=>{results.push('then after catch with val: ' + val); return 'p2 catch, then'},
12 val=>{throw new Error("mustn't be called")});
13
14 Promise.all([p1, p2]).then(res => results.push(res + ''));
15
16 drainJobQueue();
17
18 assertEq(results.length, 5);
19 assertEq(results[0], 'then result');
20 assertEq(results[1], 'catch rejection');
21 assertEq(results[2], 'chained then with val: first then rval');
22 assertEq(results[3], 'then after catch with val: 2');
23 assertEq(results[4], 'p1 then, then,p2 catch, then');
24
25 this.reportCompare && reportCompare(true,true);