diff --git a/src/function-forms/expr-named/async-func-expr-named-no-strict.template b/src/function-forms/expr-named/async-func-expr-named-no-strict.template new file mode 100644 index 0000000000..bfb99bcff7 --- /dev/null +++ b/src/function-forms/expr-named/async-func-expr-named-no-strict.template @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/async-function/named- +name: async function named expression in non-strict mode code +esid: sec-async-function-definitions +info: | + Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +flags: [async, noStrict] +features: [async-functions] +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function BindingIdentifier() { + /*{ body }*/ +}; + +(async () => { + assert.sameValue(await ref(), ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +})().then($DONE, $DONE); + diff --git a/src/function-forms/expr-named/async-func-expr-named-strict-error.template b/src/function-forms/expr-named/async-func-expr-named-strict-error.template new file mode 100644 index 0000000000..e58a44f99a --- /dev/null +++ b/src/function-forms/expr-named/async-func-expr-named-strict-error.template @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/async-function/named-strict-error- +name: async function named expression in strict mode code +esid: sec-async-function-definitions +info: | + Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +features: [async-functions] +flags: [async, onlyStrict] +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function BindingIdentifier() { + /*{ body }*/ +}; + +(async () => { + let catchCount = 0; + try { + await ref() + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +})().then($DONE, $DONE); + diff --git a/src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template b/src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template new file mode 100644 index 0000000000..3518f3aa72 --- /dev/null +++ b/src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/async-generator/named-no-strict- +name: async generator named function expression in non-strict mode code +esid: sec-asyncgenerator-definitions-evaluation +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +features: [async-iteration] +flags: [async, noStrict] +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + /*{ body }*/ +}; + +(async () => { + assert.sameValue((await (await ref()).next()).value, ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +})().then($DONE, $DONE); + diff --git a/src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template b/src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template new file mode 100644 index 0000000000..c95d75dd26 --- /dev/null +++ b/src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/async-generator/named-strict-error- +name: async generator named function expression in strict mode code +esid: sec-asyncgenerator-definitions-evaluation +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +features: [async-iteration] +flags: [async, onlyStrict] +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + /*{ body }*/ +}; + +(async () => { + let catchCount = 0; + try { + (await (await ref()).next()).value + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +})().then($DONE, $DONE); + diff --git a/src/function-forms/expr-named/func-expr-named-no-strict.template b/src/function-forms/expr-named/func-expr-named-no-strict.template new file mode 100644 index 0000000000..96ee41b25c --- /dev/null +++ b/src/function-forms/expr-named/func-expr-named-no-strict.template @@ -0,0 +1,20 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/function/named-no-strict- +name: named function expression in non-strict mode code +esid: sec-function-definitions-runtime-semantics-evaluation +info: | + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + +flags: [noStrict] +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function BindingIdentifier() { + /*{ body }*/ +}; + +assert.sameValue(ref(), ref); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/src/function-forms/expr-named/func-expr-named-strict-error.template b/src/function-forms/expr-named/func-expr-named-strict-error.template new file mode 100644 index 0000000000..db80424c17 --- /dev/null +++ b/src/function-forms/expr-named/func-expr-named-strict-error.template @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/function/named-strict-error- +name: named function expression in strict mode code +esid: sec-function-definitions-runtime-semantics-evaluation +info: | + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + +flags: [onlyStrict] +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function BindingIdentifier() { + /*{ body }*/ +}; + +assert.throws(TypeError, () => { + ref(); +}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/src/function-forms/expr-named/gen-func-expr-named-no-strict.template b/src/function-forms/expr-named/gen-func-expr-named-no-strict.template new file mode 100644 index 0000000000..ad2a51e9e6 --- /dev/null +++ b/src/function-forms/expr-named/gen-func-expr-named-no-strict.template @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/generators/named-no-strict- +name: named generator function expression in non-strict mode code +esid: sec-generator-function-definitions-runtime-semantics-evaluation +info: | + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + +features: [generators] +flags: [noStrict] +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function * BindingIdentifier() { + /*{ body }*/ +}; + +assert.sameValue(ref().next().value, ref); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/src/function-forms/expr-named/gen-func-expr-named-strict-error.template b/src/function-forms/expr-named/gen-func-expr-named-strict-error.template new file mode 100644 index 0000000000..489c29d850 --- /dev/null +++ b/src/function-forms/expr-named/gen-func-expr-named-strict-error.template @@ -0,0 +1,23 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/generators/named-strict-error- +name: named generator function expression in strict mode code +esid: sec-generator-function-definitions-runtime-semantics-evaluation +info: | + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + +features: [generators] +flags: [onlyStrict] +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function * BindingIdentifier() { + /*{ body }*/ +}; + +assert.throws(TypeError, () => { + ref().next(); +}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/src/function-forms/reassign-fn-name-in-body-in-arrow.case b/src/function-forms/reassign-fn-name-in-body-in-arrow.case new file mode 100644 index 0000000000..9abe0123d3 --- /dev/null +++ b/src/function-forms/reassign-fn-name-in-body-in-arrow.case @@ -0,0 +1,13 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Reassignment of function name is silently ignored in non-strict mode code. +template: expr-named +---*/ + +//- body +callCount++; +(() => { + BindingIdentifier = 1; +})(); +return BindingIdentifier; diff --git a/src/function-forms/reassign-fn-name-in-body-in-eval.case b/src/function-forms/reassign-fn-name-in-body-in-eval.case new file mode 100644 index 0000000000..78f7e23dbd --- /dev/null +++ b/src/function-forms/reassign-fn-name-in-body-in-eval.case @@ -0,0 +1,11 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Reassignment of function name is silently ignored in non-strict mode code. +template: expr-named +---*/ + +//- body +callCount++; +eval("BindingIdentifier = 1"); +return BindingIdentifier; diff --git a/src/function-forms/reassign-fn-name-in-body.case b/src/function-forms/reassign-fn-name-in-body.case new file mode 100644 index 0000000000..cdbd7d15f6 --- /dev/null +++ b/src/function-forms/reassign-fn-name-in-body.case @@ -0,0 +1,11 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Reassignment of function name is silently ignored in non-strict mode code. +template: expr-named +---*/ + +//- body +callCount++; +BindingIdentifier = 1; +return BindingIdentifier; diff --git a/test/language/expressions/async-function/named-reassign-fn-name-in-body-in-arrow.js b/test/language/expressions/async-function/named-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..e9b28d563d --- /dev/null +++ b/test/language/expressions/async-function/named-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/async-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async function named expression in non-strict mode code) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async, noStrict] +info: | + Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +(async () => { + assert.sameValue(await ref(), ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-function/named-reassign-fn-name-in-body-in-eval.js b/test/language/expressions/async-function/named-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..3fe24af3a3 --- /dev/null +++ b/test/language/expressions/async-function/named-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/async-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async function named expression in non-strict mode code) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async, noStrict] +info: | + Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +(async () => { + assert.sameValue(await ref(), ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-function/named-reassign-fn-name-in-body.js b/test/language/expressions/async-function/named-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..706da61679 --- /dev/null +++ b/test/language/expressions/async-function/named-reassign-fn-name-in-body.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/async-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async function named expression in non-strict mode code) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async, noStrict] +info: | + Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +(async () => { + assert.sameValue(await ref(), ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body-in-arrow.js b/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..fed64b3cd4 --- /dev/null +++ b/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/async-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async function named expression in strict mode code) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async, onlyStrict] +info: | + Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +(async () => { + let catchCount = 0; + try { + await ref() + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body-in-eval.js b/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..9b00d60f60 --- /dev/null +++ b/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/async-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async function named expression in strict mode code) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async, onlyStrict] +info: | + Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +(async () => { + let catchCount = 0; + try { + await ref() + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body.js b/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..8c07fc967b --- /dev/null +++ b/test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/async-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async function named expression in strict mode code) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async, onlyStrict] +info: | + Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +(async () => { + let catchCount = 0; + try { + await ref() + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-arrow.js b/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..3a3e19057b --- /dev/null +++ b/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in non-strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, noStrict] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +(async () => { + assert.sameValue((await (await ref()).next()).value, ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-eval.js b/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..1f0dcb1a07 --- /dev/null +++ b/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in non-strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, noStrict] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +(async () => { + assert.sameValue((await (await ref()).next()).value, ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body.js b/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..a56ecd7f24 --- /dev/null +++ b/test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/async-gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in non-strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, noStrict] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +(async () => { + assert.sameValue((await (await ref()).next()).value, ref); + assert.sameValue(callCount, 1, 'function invoked exactly once'); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-arrow.js b/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..57164314f3 --- /dev/null +++ b/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, onlyStrict] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +(async () => { + let catchCount = 0; + try { + (await (await ref()).next()).value + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-eval.js b/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..f158484f23 --- /dev/null +++ b/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, onlyStrict] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +(async () => { + let catchCount = 0; + try { + (await (await ref()).next()).value + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body.js b/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..9b6109e74c --- /dev/null +++ b/test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/async-gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (async generator named function expression in strict mode code) +esid: sec-asyncgenerator-definitions-evaluation +features: [async-iteration] +flags: [generated, async, onlyStrict] +info: | + AsyncGeneratorExpression : + async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = async function * BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +(async () => { + let catchCount = 0; + try { + (await (await ref()).next()).value + } catch (error) { + catchCount++; + assert(error instanceof TypeError); + } + assert.sameValue(catchCount, 1); + assert.sameValue(callCount, 1); +})().then($DONE, $DONE); + diff --git a/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body-in-arrow.js b/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..f15b4f56e6 --- /dev/null +++ b/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,24 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named function expression in non-strict mode code) +esid: sec-function-definitions-runtime-semantics-evaluation +flags: [generated, noStrict] +info: | + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +assert.sameValue(ref(), ref); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body-in-eval.js b/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..07c692379c --- /dev/null +++ b/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named function expression in non-strict mode code) +esid: sec-function-definitions-runtime-semantics-evaluation +flags: [generated, noStrict] +info: | + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +assert.sameValue(ref(), ref); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body.js b/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..942238b3dd --- /dev/null +++ b/test/language/expressions/function/named-no-strict-reassign-fn-name-in-body.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named function expression in non-strict mode code) +esid: sec-function-definitions-runtime-semantics-evaluation +flags: [generated, noStrict] +info: | + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +assert.sameValue(ref(), ref); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-arrow.js b/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..67562fc411 --- /dev/null +++ b/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named function expression in strict mode code) +esid: sec-function-definitions-runtime-semantics-evaluation +flags: [generated, onlyStrict] +info: | + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +assert.throws(TypeError, () => { + ref(); +}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-eval.js b/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..7958df7d36 --- /dev/null +++ b/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,24 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named function expression in strict mode code) +esid: sec-function-definitions-runtime-semantics-evaluation +flags: [generated, onlyStrict] +info: | + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +assert.throws(TypeError, () => { + ref(); +}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body.js b/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..2f5570a78a --- /dev/null +++ b/test/language/expressions/function/named-strict-error-reassign-fn-name-in-body.js @@ -0,0 +1,24 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named function expression in strict mode code) +esid: sec-function-definitions-runtime-semantics-evaluation +flags: [generated, onlyStrict] +info: | + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +assert.throws(TypeError, () => { + ref(); +}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body-in-arrow.js b/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..b59383092d --- /dev/null +++ b/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named generator function expression in non-strict mode code) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated, noStrict] +info: | + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function * BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +assert.sameValue(ref().next().value, ref); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body-in-eval.js b/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..cec56cce9b --- /dev/null +++ b/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,23 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named generator function expression in non-strict mode code) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated, noStrict] +info: | + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function * BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +assert.sameValue(ref().next().value, ref); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body.js b/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..f10a06fa62 --- /dev/null +++ b/test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body.js @@ -0,0 +1,23 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/gen-func-expr-named-no-strict.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named generator function expression in non-strict mode code) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated, noStrict] +info: | + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function * BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +assert.sameValue(ref().next().value, ref); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-arrow.js b/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-arrow.js new file mode 100644 index 0000000000..232175e8d4 --- /dev/null +++ b/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-arrow.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-arrow.case +// - src/function-forms/expr-named/gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named generator function expression in strict mode code) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated, onlyStrict] +info: | + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function * BindingIdentifier() { + callCount++; + (() => { + BindingIdentifier = 1; + })(); + return BindingIdentifier; +}; + +assert.throws(TypeError, () => { + ref().next(); +}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-eval.js b/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-eval.js new file mode 100644 index 0000000000..0244403c72 --- /dev/null +++ b/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-eval.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body-in-eval.case +// - src/function-forms/expr-named/gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named generator function expression in strict mode code) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated, onlyStrict] +info: | + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function * BindingIdentifier() { + callCount++; + eval("BindingIdentifier = 1"); + return BindingIdentifier; +}; + +assert.throws(TypeError, () => { + ref().next(); +}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body.js b/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body.js new file mode 100644 index 0000000000..460f947b1b --- /dev/null +++ b/test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/reassign-fn-name-in-body.case +// - src/function-forms/expr-named/gen-func-expr-named-strict-error.template +/*--- +description: Reassignment of function name is silently ignored in non-strict mode code. (named generator function expression in strict mode code) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated, onlyStrict] +info: | + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + +---*/ + +// increment callCount in case "body" +let callCount = 0; +let ref = function * BindingIdentifier() { + callCount++; + BindingIdentifier = 1; + return BindingIdentifier; +}; + +assert.throws(TypeError, () => { + ref().next(); +}); +assert.sameValue(callCount, 1, 'function invoked exactly once');