mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 00:14:35 +02:00
Promise.allSettled: coverage updates, R2 (#2684)
This commit is contained in:
parent
836f609b08
commit
16b48a1271
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-performpromiseallsettled
|
||||||
|
description: >
|
||||||
|
Cannot tamper with remainingElementsCount when Promise.allSettled reject element function is called multiple times.
|
||||||
|
info: |
|
||||||
|
Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability, )
|
||||||
|
|
||||||
|
If alreadyCalled.[[Value]] is true, return undefined.
|
||||||
|
|
||||||
|
features: [Promise.allSettled]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let rejectCallCount = 0;
|
||||||
|
let returnValue = {};
|
||||||
|
let error = new Test262Error();
|
||||||
|
|
||||||
|
function Constructor(executor) {
|
||||||
|
function reject(value) {
|
||||||
|
assert.sameValue(value, error);
|
||||||
|
rejectCallCount += 1;
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
executor(() => {throw error}, reject);
|
||||||
|
}
|
||||||
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
Constructor.reject = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
|
let pOnRejected;
|
||||||
|
|
||||||
|
let p = {
|
||||||
|
then(onResolved, onRejected) {
|
||||||
|
pOnRejected = onRejected;
|
||||||
|
onResolved();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(rejectCallCount, 0, 'rejectCallCount before call to allSettled()');
|
||||||
|
|
||||||
|
Promise.allSettled.call(Constructor, [p]);
|
||||||
|
|
||||||
|
assert.sameValue(rejectCallCount, 1, 'rejectCallCount after call to allSettled()');
|
||||||
|
assert.sameValue(pOnRejected(), undefined);
|
||||||
|
assert.sameValue(rejectCallCount, 1, 'rejectCallCount after call to pOnRejected()');
|
||||||
|
pOnRejected();
|
||||||
|
assert.sameValue(rejectCallCount, 1, 'rejectCallCount after call to pOnRejected()');
|
||||||
|
|
||||||
|
|
@ -71,11 +71,11 @@ var p3 = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
assert.sameValue(callCount, 0, 'callCount before call to all()');
|
assert.sameValue(callCount, 0, 'callCount before call to allSettled()');
|
||||||
|
|
||||||
Promise.allSettled.call(Constructor, [p1, p2, p3]);
|
Promise.allSettled.call(Constructor, [p1, p2, p3]);
|
||||||
|
|
||||||
assert.sameValue(callCount, 0, 'callCount after call to all()');
|
assert.sameValue(callCount, 0, 'callCount after call to allSettled()');
|
||||||
|
|
||||||
p1OnFulfilled('p1-fulfill');
|
p1OnFulfilled('p1-fulfill');
|
||||||
p1OnFulfilled('p1-fulfill-unexpected-1');
|
p1OnFulfilled('p1-fulfill-unexpected-1');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user