mirror of
https://github.com/tc39/test262.git
synced 2025-07-21 13:04:39 +02:00
Add tests for rejected %AsyncIteratorPrototype%.@@asyncDispose
This commit is contained in:
parent
2e59aad8d1
commit
5e201642db
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2025 Sosuke Suzuki. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%asynciteratorprototype%-@@asyncDispose
|
||||||
|
description: rejects if `return` returns rejected promise
|
||||||
|
info: |
|
||||||
|
%AsyncIteratorPrototype% [ @@asyncDispose ] ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
6. Else,
|
||||||
|
a. Let result be Call(return, O, « undefined »).
|
||||||
|
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||||
|
...
|
||||||
|
|
||||||
|
features: [explicit-resource-management]
|
||||||
|
includes: [asyncHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
async function* generator() {}
|
||||||
|
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype));
|
||||||
|
|
||||||
|
var returnCount = 0;
|
||||||
|
|
||||||
|
function CatchError() {}
|
||||||
|
|
||||||
|
const obj = {
|
||||||
|
return() {
|
||||||
|
returnCount++;
|
||||||
|
return Promise.reject(new CatchError());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
asyncTest(async function () {
|
||||||
|
await assert.throwsAsync(CatchError, function () {
|
||||||
|
return AsyncIteratorPrototype[Symbol.asyncDispose].call(obj);
|
||||||
|
}, "Promise should be rejected");
|
||||||
|
assert.sameValue(returnCount, 1);
|
||||||
|
});
|
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2025 Sosuke Suzuki. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%asynciteratorprototype%-@@asyncDispose
|
||||||
|
description: rejects if `return` getter throws
|
||||||
|
info: |
|
||||||
|
%AsyncIteratorPrototype% [ @@asyncDispose ] ( )
|
||||||
|
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. Let promiseCapability be ! NewPromiseCapability(%Promise%).
|
||||||
|
3. Let return be GetMethod(O, "return").
|
||||||
|
4. IfAbruptRejectPromise(return, promiseCapability).
|
||||||
|
...
|
||||||
|
|
||||||
|
features: [explicit-resource-management]
|
||||||
|
includes: [asyncHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
async function* generator() {}
|
||||||
|
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype));
|
||||||
|
|
||||||
|
var returnGetCount = 0;
|
||||||
|
|
||||||
|
function CatchError() {}
|
||||||
|
|
||||||
|
const obj = {
|
||||||
|
get return() {
|
||||||
|
returnGetCount++;
|
||||||
|
throw new CatchError();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
asyncTest(async function () {
|
||||||
|
await assert.throwsAsync(CatchError, function () {
|
||||||
|
return AsyncIteratorPrototype[Symbol.asyncDispose].call(obj);
|
||||||
|
}, "Promise should be rejected");
|
||||||
|
assert.sameValue(returnGetCount, 1);
|
||||||
|
});
|
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2025 Sosuke Suzuki. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%asynciteratorprototype%-@@asyncDispose
|
||||||
|
description: rejects if `return` throws
|
||||||
|
info: |
|
||||||
|
%AsyncIteratorPrototype% [ @@asyncDispose ] ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
6. Else,
|
||||||
|
a. Let result be Call(return, O, « undefined »).
|
||||||
|
b. IfAbruptRejectPromise(result, promiseCapability).
|
||||||
|
...
|
||||||
|
|
||||||
|
features: [explicit-resource-management]
|
||||||
|
includes: [asyncHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
async function* generator() {}
|
||||||
|
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype));
|
||||||
|
|
||||||
|
var returnCount = 0;
|
||||||
|
|
||||||
|
function CatchError() {}
|
||||||
|
|
||||||
|
const obj = {
|
||||||
|
return() {
|
||||||
|
returnCount++;
|
||||||
|
throw new CatchError();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
asyncTest(async function () {
|
||||||
|
await assert.throwsAsync(CatchError, function () {
|
||||||
|
return AsyncIteratorPrototype[Symbol.asyncDispose].call(obj);
|
||||||
|
}, "Promise should be rejected");
|
||||||
|
assert.sameValue(returnCount, 1);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user