resolve-from-same-thenable.js (1017B)
1 // Copyright (C) 2020 Rick Waldron. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-performpromiseany 6 description: > 7 Promise.any does not prevent resolve from being called multiple times. 8 features: [Promise.any, arrow-function] 9 includes: [promiseHelper.js] 10 ---*/ 11 let callCount = 0; 12 let sequence = []; 13 14 function Constructor(executor) { 15 function resolve(value) { 16 callCount += 1; 17 sequence.push(value); 18 } 19 executor(resolve, Test262Error.thrower); 20 } 21 Constructor.resolve = function(v) { 22 return v; 23 }; 24 25 let pResolve; 26 let a = { 27 then(resolver, rejector) { 28 pResolve = resolver; 29 } 30 }; 31 32 assert.sameValue(callCount, 0, 'callCount before call to any()'); 33 34 Promise.any.call(Constructor, [a]); 35 36 assert.sameValue(callCount, 0, 'callCount after call to any()'); 37 38 pResolve(1); 39 pResolve(2); 40 pResolve(3); 41 42 assert.sameValue(callCount, 3, 'callCount after resolving a'); 43 assert.sameValue(sequence.length, 3); 44 checkSequence(sequence); 45 46 reportCompare(0, 0);