mirror of https://github.com/tc39/test262.git
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
author: Caitlin Potter <caitp@igalia.com>
|
|
esid: pending
|
|
description: >
|
|
Thrown generator suspended in a yield position resumes execution within
|
|
the associated catch-block
|
|
info: |
|
|
AsyncGeneratorResumeNext:
|
|
If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is
|
|
"suspendedYield", and generator is resumed within a try-block with an
|
|
associated catch block, resume execution within catch-block.
|
|
flags: [async]
|
|
features: [async-iteration]
|
|
---*/
|
|
|
|
var error = new Error('boop');
|
|
var g = async function*() {
|
|
try {
|
|
yield 1;
|
|
throw new Test262Error('Generator must be resumed in catch block.');
|
|
} catch (err) {
|
|
assert.sameValue(err, error);
|
|
return 'done';
|
|
}
|
|
};
|
|
|
|
var it = g();
|
|
it.next().then(function(ret) {
|
|
assert.sameValue(ret.value, 1, 'Initial yield');
|
|
assert.sameValue(ret.done, false, 'Initial yield');
|
|
|
|
it.throw(error).then(function(ret) {
|
|
assert.sameValue(ret.value, 'done', 'AsyncGeneratorResolve(generator, resultValue, true)');
|
|
assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)');
|
|
|
|
it.next().then(function(ret) {
|
|
assert.sameValue(ret.value, undefined, 'Generator is closed');
|
|
assert.sameValue(ret.done, true, 'Generator is closed');
|
|
}).then($DONE, $DONE);
|
|
|
|
}).catch($DONE);
|
|
|
|
}).catch($DONE);
|