instance-yield-expr-in-param.js (1357B)
1 // |reftest| async 2 // Copyright (C) 2018 Valerie Young. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 esid: sec-asyncgeneratorfunction 6 description: Definition of instance `length` property 7 info: | 8 AsyncGeneratorFunction ( p1, p2, … , pn, body ) 9 ... 10 3. Return CreateDynamicFunction(C, NewTarget, "async generator", args). 11 12 Runtime Semantics: CreateDynamicFunction 13 ... 14 28. If kind is "generator" or "async generator", then 15 a. If parameters Contains YieldExpression is true, throw a SyntaxError 16 exception. 17 features: [async-iteration] 18 flags: [async] 19 ---*/ 20 21 var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; 22 23 // YieldExpression is permitted in function body. 24 AsyncGeneratorFunction('x = yield'); 25 26 assert.throws(SyntaxError, function() { 27 AsyncGeneratorFunction('x = yield', ''); 28 }, 'YieldExpression not permitted generally'); 29 30 var withinAsyncGenerator = async function*() { 31 AsyncGeneratorFunction('x = yield', ''); 32 }; 33 34 withinAsyncGenerator().next().then( 35 function () { 36 throw new Test262Error("YieldExpression not permitted when calling context is a async generator"); 37 }, 38 function (e) { 39 if (!(e instanceof SyntaxError)) { 40 throw new Test262Error("Expected SyntaxError but got " + e); 41 } 42 } 43 ).then($DONE, $DONE);