From bb838d8d6bdcf542d6c8413d076be4c5ca8b27b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Mon, 11 Mar 2019 10:34:38 -0700 Subject: [PATCH] Add test when IteratorValue argument to AsyncGeneratorYield in yield* throws --- ...d-star-normal-notdone-iter-value-throws.js | 53 +++++++++++++++ ...d-star-return-notdone-iter-value-throws.js | 63 ++++++++++++++++++ ...ld-star-throw-notdone-iter-value-throws.js | 64 +++++++++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 test/language/statements/async-generator/yield-star-normal-notdone-iter-value-throws.js create mode 100644 test/language/statements/async-generator/yield-star-return-notdone-iter-value-throws.js create mode 100644 test/language/statements/async-generator/yield-star-throw-notdone-iter-value-throws.js diff --git a/test/language/statements/async-generator/yield-star-normal-notdone-iter-value-throws.js b/test/language/statements/async-generator/yield-star-normal-notdone-iter-value-throws.js new file mode 100644 index 0000000000..b2035b35fa --- /dev/null +++ b/test/language/statements/async-generator/yield-star-normal-notdone-iter-value-throws.js @@ -0,0 +1,53 @@ +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + Abrupt completion when calling IteratorValue is propagated when received.[[Type]] is normal. +info: | + 14.4.14 Runtime Semantics: Evaluation + YieldExpression : yield* AssignmentExpression + + ... + 7. Repeat, + a. If received.[[Type]] is normal, then + ... + vi. If generatorKind is async, then set received to AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + +flags: [async] +features: [async-iteration] +---*/ + +var token = {}; + +var asyncIter = { + [Symbol.asyncIterator]() { + return this; + }, + next() { + return { + done: false, + get value() { + throw token; + } + }; + } +}; + +async function* f() { + var thrown; + try { + yield* asyncIter; + } catch (e) { + thrown = e; + } + return thrown; +} + +var iter = f(); + +iter.next().then(({value}) => { + assert.sameValue(value, token); +}).then($DONE, $DONE); diff --git a/test/language/statements/async-generator/yield-star-return-notdone-iter-value-throws.js b/test/language/statements/async-generator/yield-star-return-notdone-iter-value-throws.js new file mode 100644 index 0000000000..bdfceda8d1 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-return-notdone-iter-value-throws.js @@ -0,0 +1,63 @@ +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + Abrupt completion when calling IteratorValue is propagated when received.[[Type]] is return. +info: | + 14.4.14 Runtime Semantics: Evaluation + YieldExpression : yield* AssignmentExpression + + ... + 7. Repeat, + ... + c. Else, + i. Assert: received.[[Type]] is return. + ... + ix. If generatorKind is async, then set received to AsyncGeneratorYield(? IteratorValue(innerReturnResult)). + ... + +flags: [async] +features: [async-iteration] +---*/ + +var token = {}; + +var asyncIter = { + [Symbol.asyncIterator]() { + return this; + }, + next() { + return { + done: false, + value: undefined, + }; + }, + return() { + return { + done: false, + get value() { + throw token; + } + }; + } +}; + +async function* f() { + var thrown; + try { + yield* asyncIter; + } catch (e) { + thrown = e; + } + return thrown; +} + +var iter = f(); + +iter.next().then(() => { + iter.return().then(({value}) => { + assert.sameValue(value, token); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/test/language/statements/async-generator/yield-star-throw-notdone-iter-value-throws.js b/test/language/statements/async-generator/yield-star-throw-notdone-iter-value-throws.js new file mode 100644 index 0000000000..dba6e808d3 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-throw-notdone-iter-value-throws.js @@ -0,0 +1,64 @@ +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: > + Abrupt completion when calling IteratorValue is propagated when received.[[Type]] is throw. +info: | + 14.4.14 Runtime Semantics: Evaluation + YieldExpression : yield* AssignmentExpression + + ... + 7. Repeat, + ... + b. Else if received.[[Type]] is throw, then + ... + ii. If throw is not undefined, then + ... + 7. If generatorKind is async, then set received to AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + +flags: [async] +features: [async-iteration] +---*/ + +var token = {}; + +var asyncIter = { + [Symbol.asyncIterator]() { + return this; + }, + next() { + return { + done: false, + value: undefined, + }; + }, + throw() { + return { + done: false, + get value() { + throw token; + } + }; + } +}; + +async function* f() { + var thrown; + try { + yield* asyncIter; + } catch (e) { + thrown = e; + } + return thrown; +} + +var iter = f(); + +iter.next().then(() => { + iter.throw().then(({value}) => { + assert.sameValue(value, token); + }).then($DONE, $DONE); +}).catch($DONE);