From a82f5382ff52cbdb3c976c393db39a158f58ce2f Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Mon, 8 Apr 2024 18:14:17 +0100 Subject: [PATCH] Remove 'AsyncArrowFunction' test There is no such hidden constructor, it's the same as the hidden AsyncFunction constructor. In other words: ```js Object.getPrototypeOf(async () => {}).constructor === Object.getPrototypeOf(async function () {}).constructor ``` Also add a test to ensure that %AsyncFunction.prototype% is indeed the prototype of an async arrow function. Closes #4044. --- harness/hidden-constructors.js | 2 -- .../AsyncArrowFunction/is-a-constructor.js | 24 ------------------- .../async-arrow-function/prototype.js | 17 +++++++++++++ 3 files changed, 17 insertions(+), 26 deletions(-) delete mode 100644 test/built-ins/AsyncArrowFunction/is-a-constructor.js create mode 100644 test/language/expressions/async-arrow-function/prototype.js diff --git a/harness/hidden-constructors.js b/harness/hidden-constructors.js index 124ca19bb7..8a517475a2 100644 --- a/harness/hidden-constructors.js +++ b/harness/hidden-constructors.js @@ -5,13 +5,11 @@ description: | Provides uniform access to built-in constructors that are not exposed to the global object. defines: - - AsyncArrowFunction - AsyncFunction - AsyncGeneratorFunction - GeneratorFunction ---*/ -var AsyncArrowFunction = Object.getPrototypeOf(async () => {}).constructor; var AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; diff --git a/test/built-ins/AsyncArrowFunction/is-a-constructor.js b/test/built-ins/AsyncArrowFunction/is-a-constructor.js deleted file mode 100644 index acbc03d958..0000000000 --- a/test/built-ins/AsyncArrowFunction/is-a-constructor.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-ecmascript-standard-built-in-objects -description: > - The AsyncArrowFunction constructor implements [[Construct]] -info: | - IsConstructor ( argument ) - - The abstract operation IsConstructor takes argument argument (an ECMAScript language value). - It determines if argument is a function object with a [[Construct]] internal method. - It performs the following steps when called: - - If Type(argument) is not Object, return false. - If argument has a [[Construct]] internal method, return true. - Return false. -includes: [isConstructor.js, hidden-constructors.js] -features: [Reflect.construct] ----*/ - -assert.sameValue(isConstructor(AsyncArrowFunction), true, 'isConstructor(AsyncArrowFunction) must return true'); -new AsyncArrowFunction(); - diff --git a/test/language/expressions/async-arrow-function/prototype.js b/test/language/expressions/async-arrow-function/prototype.js new file mode 100644 index 0000000000..ef2785c7b9 --- /dev/null +++ b/test/language/expressions/async-arrow-function/prototype.js @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Linus Groh. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-async-arrow-function-definitions-runtime-semantics-evaluation +description: The prototype of an async arrow function is %AsyncFunction.prototype%. +info: | + AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody + + ... + 6. Let closure be OrdinaryFunctionCreate(%AsyncFunction.prototype%, sourceText, parameters, + AsyncConciseBody, lexical-this, env, privateEnv). + ... +includes: [hidden-constructors.js] +---*/ + +assert.sameValue(Object.getPrototypeOf(async () => {}), AsyncFunction.prototype);