new-reject-function.js (1294B)
1 // Copyright (C) 2019 Leo Balter. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-performpromiseallsettled 6 description: > 7 Each Promise.allSettled element is called with a new Promise.allSettled Reject Element function. 8 info: | 9 Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability ) 10 11 ... 12 z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »). 13 ... 14 features: [Promise.allSettled] 15 ---*/ 16 17 function rejectFunction() {} 18 19 function Constructor(executor) { 20 executor(rejectFunction, Test262Error.thrower); 21 } 22 Constructor.resolve = function(v) { 23 return v; 24 }; 25 26 var callCount1 = 0, 27 callCount2 = 0; 28 var p1OnRejected; 29 30 var p1 = { 31 then(_, onRejected) { 32 callCount1 += 1; 33 p1OnRejected = onRejected; 34 assert.notSameValue(onRejected, rejectFunction, 'p1.then'); 35 } 36 }; 37 var p2 = { 38 then(_, onRejected) { 39 callCount2 += 1; 40 assert.notSameValue(onRejected, rejectFunction, 'p2.then'); 41 assert.notSameValue(onRejected, p1OnRejected, 'p1.onRejected != p2.onRejected'); 42 } 43 }; 44 45 Promise.allSettled.call(Constructor, [p1, p2]); 46 47 assert.sameValue(callCount1, 1, 'p1.then call count'); 48 assert.sameValue(callCount2, 1, 'p2.then call count'); 49 50 reportCompare(0, 0);