From 141570268946a526af8972978efe4c79ae98ee8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Thu, 15 Aug 2019 07:36:30 -0700 Subject: [PATCH] Assign "name" property to all anonymous functions Implements the changes from . --- .../all/resolve-element-function-name.js | 16 +++-- .../reject-element-function-name.js | 16 +++-- .../resolve-element-function-name.js | 19 +++--- .../Promise/executor-function-name.js | 16 +++-- .../built-ins/Promise/reject-function-name.js | 16 +++-- .../Promise/resolve-function-name.js | 16 +++-- .../revocable/revocation-function-name.js | 15 +++-- test/built-ins/ThrowTypeError/name.js | 21 ++++++- .../compare/compare-function-name.js | 20 ++++--- .../prototype/format/format-function-name.js | 20 ++++--- .../prototype/format/format-function-name.js | 20 ++++--- .../class/static/method-number.js | 6 +- .../class/static/method-string.js | 6 +- .../class/static/method-symbol.js | 6 +- .../expressions/arrow-function/name.js | 24 ++++++++ .../assignment/fn-name-lhs-cover.js | 20 +++---- .../assignment/fn-name-lhs-member.js | 20 +++---- .../expressions/async-arrow-function/name.js | 35 +++++++++++ .../expressions/async-function/name.js | 36 +++++++++++ .../expressions/async-generator/name.js | 36 +++++++++++ test/language/expressions/class/name.js | 60 +++++++++++++------ test/language/expressions/function/name.js | 39 ++++++------ test/language/expressions/generators/name.js | 35 ++++++----- 23 files changed, 373 insertions(+), 145 deletions(-) create mode 100644 test/language/expressions/arrow-function/name.js create mode 100644 test/language/expressions/async-arrow-function/name.js create mode 100644 test/language/expressions/async-function/name.js create mode 100644 test/language/expressions/async-generator/name.js diff --git a/test/built-ins/Promise/all/resolve-element-function-name.js b/test/built-ins/Promise/all/resolve-element-function-name.js index e743dba347e..a7b6b518fa3 100644 --- a/test/built-ins/Promise/all/resolve-element-function-name.js +++ b/test/built-ins/Promise/all/resolve-element-function-name.js @@ -8,9 +8,14 @@ info: | A promise resolve function is an anonymous built-in function. 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not - identified as an anonymous function has a name property whose value - is a String. + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] ---*/ var resolveElementFunction; @@ -28,5 +33,6 @@ NotPromise.resolve = function(v) { }; Promise.all.call(NotPromise, [thenable]); -assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, "name"), false); -assert.sameValue(resolveElementFunction.name, ""); +verifyProperty(resolveElementFunction, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/built-ins/Promise/allSettled/reject-element-function-name.js b/test/built-ins/Promise/allSettled/reject-element-function-name.js index 5f8827aacf3..2d151d4cff3 100644 --- a/test/built-ins/Promise/allSettled/reject-element-function-name.js +++ b/test/built-ins/Promise/allSettled/reject-element-function-name.js @@ -8,9 +8,14 @@ info: | A promise resolve function is an anonymous built-in function. 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not - identified as an anonymous function has a name property whose value - is a String. + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] features: [Promise.allSettled] ---*/ @@ -29,5 +34,6 @@ NotPromise.resolve = function(v) { }; Promise.allSettled.call(NotPromise, [thenable]); -assert.sameValue(Object.prototype.hasOwnProperty.call(rejectElementFunction, 'name'), false); -assert.sameValue(rejectElementFunction.name, ''); +verifyProperty(rejectElementFunction, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/built-ins/Promise/allSettled/resolve-element-function-name.js b/test/built-ins/Promise/allSettled/resolve-element-function-name.js index 2df8fb8093d..cee04bfea8d 100644 --- a/test/built-ins/Promise/allSettled/resolve-element-function-name.js +++ b/test/built-ins/Promise/allSettled/resolve-element-function-name.js @@ -8,9 +8,14 @@ info: | A promise resolve function is an anonymous built-in function. 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not - identified as an anonymous function has a name property whose value - is a String. + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] features: [Promise.allSettled] ---*/ @@ -29,8 +34,6 @@ NotPromise.resolve = function(v) { }; Promise.allSettled.call(NotPromise, [thenable]); -assert.sameValue( - Object.prototype.hasOwnProperty.call(resolveElementFunction, 'name'), - false -); -assert.sameValue(resolveElementFunction.name, ''); +verifyProperty(resolveElementFunction, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/built-ins/Promise/executor-function-name.js b/test/built-ins/Promise/executor-function-name.js index cf412cc6ce7..1551498178a 100644 --- a/test/built-ins/Promise/executor-function-name.js +++ b/test/built-ins/Promise/executor-function-name.js @@ -8,9 +8,14 @@ info: | A GetCapabilitiesExecutor function is an anonymous built-in function. 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not - identified as an anonymous function has a name property whose value - is a String. + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] ---*/ var executorFunction; @@ -21,5 +26,6 @@ function NotPromise(executor) { } Promise.resolve.call(NotPromise); -assert.sameValue(Object.prototype.hasOwnProperty.call(executorFunction, "name"), false); -assert.sameValue(executorFunction.name, ""); +verifyProperty(executorFunction, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/built-ins/Promise/reject-function-name.js b/test/built-ins/Promise/reject-function-name.js index af642446840..b5c0ccbff56 100644 --- a/test/built-ins/Promise/reject-function-name.js +++ b/test/built-ins/Promise/reject-function-name.js @@ -8,9 +8,14 @@ info: | A promise reject function is an anonymous built-in function. 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not - identified as an anonymous function has a name property whose value - is a String. + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] ---*/ var rejectFunction; @@ -18,5 +23,6 @@ new Promise(function(resolve, reject) { rejectFunction = reject; }); -assert.sameValue(Object.prototype.hasOwnProperty.call(rejectFunction, "name"), false); -assert.sameValue(rejectFunction.name, ""); +verifyProperty(rejectFunction, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/built-ins/Promise/resolve-function-name.js b/test/built-ins/Promise/resolve-function-name.js index afaec3aaf65..d34175d9856 100644 --- a/test/built-ins/Promise/resolve-function-name.js +++ b/test/built-ins/Promise/resolve-function-name.js @@ -8,9 +8,14 @@ info: | A promise resolve function is an anonymous built-in function. 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not - identified as an anonymous function has a name property whose value - is a String. + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] ---*/ var resolveFunction; @@ -18,5 +23,6 @@ new Promise(function(resolve, reject) { resolveFunction = resolve; }); -assert.sameValue(Object.prototype.hasOwnProperty.call(resolveFunction, "name"), false); -assert.sameValue(resolveFunction.name, ""); +verifyProperty(resolveFunction, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/built-ins/Proxy/revocable/revocation-function-name.js b/test/built-ins/Proxy/revocable/revocation-function-name.js index 7c9045d20f7..b6391fe8378 100644 --- a/test/built-ins/Proxy/revocable/revocation-function-name.js +++ b/test/built-ins/Proxy/revocable/revocation-function-name.js @@ -8,12 +8,19 @@ info: | A Proxy revocation function is an anonymous function. 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not - identified as an anonymous function has a name property whose value - is a String. + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] features: [Proxy] ---*/ var revocationFunction = Proxy.revocable({}, {}).revoke; -assert.sameValue(Object.prototype.hasOwnProperty.call(revocationFunction, "name"), false); +verifyProperty(revocationFunction, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/built-ins/ThrowTypeError/name.js b/test/built-ins/ThrowTypeError/name.js index d894ee12f35..46a79d32445 100644 --- a/test/built-ins/ThrowTypeError/name.js +++ b/test/built-ins/ThrowTypeError/name.js @@ -8,8 +8,21 @@ description: > info: | %ThrowTypeError% ( ) - The %ThrowTypeError% intrinsic is an anonymous built-in function - object that is defined once for each Realm. + 9.2.9.1 %ThrowTypeError% ( ) + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each Realm. The `name` property of a + %ThrowTypeError% function has the attributes { [[Writable]]: *false*, + [[Enumerable]]: *false*, [[Configurable]]: *false* }. + + 17 ECMAScript Standard Built-in Objects: + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] ---*/ var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { @@ -17,4 +30,6 @@ var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { return arguments; }(), "callee").get; -assert.sameValue(Object.prototype.hasOwnProperty.call(ThrowTypeError, "name"), false); +verifyProperty(ThrowTypeError, "name", { + value: "", writable: false, enumerable: false, configurable: false +}); diff --git a/test/intl402/Collator/prototype/compare/compare-function-name.js b/test/intl402/Collator/prototype/compare/compare-function-name.js index 41f936897e3..e57fbab4eb7 100644 --- a/test/intl402/Collator/prototype/compare/compare-function-name.js +++ b/test/intl402/Collator/prototype/compare/compare-function-name.js @@ -8,15 +8,19 @@ description: > info: | 10.3.3 get Intl.Collator.prototype.compare - ... - 4. If collator.[[boundCompare]] is undefined, then - a. Let F be a new built-in function object as defined in 10.3.4. - b. Let bc be BoundFunctionCreate(F, collator, « »). - c. Perform ! DefinePropertyOrThrow(bc, "length", PropertyDescriptor {[[Value]]: 2, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). - d. Set collator.[[boundCompare]] to bc. - ... + 17 ECMAScript Standard Built-in Objects: + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] ---*/ var compareFn = new Intl.Collator().compare; -assert.sameValue(Object.prototype.hasOwnProperty.call(compareFn, "name"), false); +verifyProperty(compareFn, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/intl402/DateTimeFormat/prototype/format/format-function-name.js b/test/intl402/DateTimeFormat/prototype/format/format-function-name.js index e340819a099..651ac828678 100644 --- a/test/intl402/DateTimeFormat/prototype/format/format-function-name.js +++ b/test/intl402/DateTimeFormat/prototype/format/format-function-name.js @@ -8,15 +8,19 @@ description: > info: | 12.4.3 get Intl.DateTimeFormat.prototype.compare - ... - 4. If the [[boundFormat]] internal slot of dtf is undefined, then - a. Let F be a new built-in function object as defined in DateTime Format Functions (12.1.5). - b. Let bf be BoundFunctionCreate(F, dft, « »). - c. Perform ! DefinePropertyOrThrow(bf, "length", PropertyDescriptor {[[Value]]: 1, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). - d. Set dtf.[[boundFormat]] to bf. - ... + 17 ECMAScript Standard Built-in Objects: + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] ---*/ var formatFn = new Intl.DateTimeFormat().format; -assert.sameValue(Object.prototype.hasOwnProperty.call(formatFn, "name"), false); +verifyProperty(formatFn, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/intl402/NumberFormat/prototype/format/format-function-name.js b/test/intl402/NumberFormat/prototype/format/format-function-name.js index 8cd2fc2c850..c5a9d48e063 100644 --- a/test/intl402/NumberFormat/prototype/format/format-function-name.js +++ b/test/intl402/NumberFormat/prototype/format/format-function-name.js @@ -8,15 +8,19 @@ description: > info: | 11.4.3 get Intl.NumberFormat.prototype.compare - ... - 4. If nf.[[boundFormat]] is undefined, then - a. Let F be a new built-in function object as defined in Number Format Functions (11.1.3). - b. Let bf be BoundFunctionCreate(F, nf, « »). - c. Perform ! DefinePropertyOrThrow(bf, "length", PropertyDescriptor {[[Value]]: 1, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). - d. Set nf.[[boundFormat]] to bf. - ... + 17 ECMAScript Standard Built-in Objects: + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] ---*/ var formatFn = new Intl.NumberFormat().format; -assert.sameValue(Object.prototype.hasOwnProperty.call(formatFn, "name"), false); +verifyProperty(formatFn, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/computed-property-names/class/static/method-number.js b/test/language/computed-property-names/class/static/method-number.js index c00f3e02026..e989322c3a7 100644 --- a/test/language/computed-property-names/class/static/method-number.js +++ b/test/language/computed-property-names/class/static/method-number.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 12.2.5 +esid: sec-object-initializer description: > In a class, static computed property method names can be a number includes: [compareArray.js] @@ -21,6 +21,6 @@ assert( "`compareArray(Object.keys(C), [])` returns `true`" ); assert( - compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'name', 'a', 'c']), - "`compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'name', 'a', 'c'])` returns `true`" + compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'name', 'prototype', 'a', 'c']), + "`compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'name', 'prototype', 'a', 'c'])` returns `true`" ); diff --git a/test/language/computed-property-names/class/static/method-string.js b/test/language/computed-property-names/class/static/method-string.js index 8f383805b05..8e80d6450c8 100644 --- a/test/language/computed-property-names/class/static/method-string.js +++ b/test/language/computed-property-names/class/static/method-string.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 12.2.5 +esid: sec-object-initializer description: > In a class, static computed property method names can be a string includes: [compareArray.js] @@ -21,6 +21,6 @@ assert( "`compareArray(Object.keys(C), [])` returns `true`" ); assert( - compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'b', 'c', 'd']), - "`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'b', 'c', 'd'])` returns `true`" + compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype', 'a', 'b', 'c', 'd']), + "`compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype', 'a', 'b', 'c', 'd'])` returns `true`" ); diff --git a/test/language/computed-property-names/class/static/method-symbol.js b/test/language/computed-property-names/class/static/method-symbol.js index 3eb710b7802..f09b53fd9e9 100644 --- a/test/language/computed-property-names/class/static/method-symbol.js +++ b/test/language/computed-property-names/class/static/method-symbol.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 12.2.5 +esid: sec-object-initializer description: > In a class, static computed property method names can be a symbol includes: [compareArray.js] @@ -24,8 +24,8 @@ assert( "`compareArray(Object.keys(C), [])` returns `true`" ); assert( - compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'c']), - "`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'c'])` returns `true`" + compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype', 'a', 'c']), + "`compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype', 'a', 'c'])` returns `true`" ); assert( compareArray(Object.getOwnPropertySymbols(C), [sym1, sym2]), diff --git a/test/language/expressions/arrow-function/name.js b/test/language/expressions/arrow-function/name.js new file mode 100644 index 00000000000..11a59151d8d --- /dev/null +++ b/test/language/expressions/arrow-function/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +description: Assignment of function `name` attribute +info: | + ArrowFunction : ArrowParameters => ConciseBody + + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let parameters be CoveredFormalsList of ArrowParameters. + 3. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, ""). + ... + 5. Return closure. +includes: [propertyHelper.js] +---*/ + +verifyProperty(x => {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); + +verifyProperty(() => {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/expressions/assignment/fn-name-lhs-cover.js b/test/language/expressions/assignment/fn-name-lhs-cover.js index 7474ea5bebe..cda5b01143a 100644 --- a/test/language/expressions/assignment/fn-name-lhs-cover.js +++ b/test/language/expressions/assignment/fn-name-lhs-cover.js @@ -2,26 +2,26 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 12.14.4 +esid: sec-assignment-operators-runtime-semantics-evaluation description: Left-hand side as a CoverParenthesizedExpression info: | - AssignmentExpression[In, Yield] : - LeftHandSideExpression[?Yield] = AssignmentExpression[?In, ?Yield] + AssignmentExpression[In, Yield, Await] : + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] 1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, then [...] - e. If IsAnonymousFunctionDefinition(AssignmentExpression) and + c. If IsAnonymousFunctionDefinition(AssignmentExpression) and IsIdentifierRef of LeftHandSideExpression are both true, then - - i. Let hasNameProperty be HasOwnProperty(rval, "name"). - ii. ReturnIfAbrupt(hasNameProperty). - iii. If hasNameProperty is false, perform SetFunctionName(rval, - GetReferencedName(lref)). + i. Let rval be NamedEvaluation of AssignmentExpression with argument + GetReferencedName(lref). +includes: [propertyHelper.js] ---*/ var fn; (fn) = function() {}; -assert.sameValue(Object.hasOwnProperty.call(fn, 'name'), false); +verifyProperty(fn, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/expressions/assignment/fn-name-lhs-member.js b/test/language/expressions/assignment/fn-name-lhs-member.js index 7d14d39eb0e..b85f6fc3c48 100644 --- a/test/language/expressions/assignment/fn-name-lhs-member.js +++ b/test/language/expressions/assignment/fn-name-lhs-member.js @@ -2,26 +2,26 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 12.14.4 +esid: sec-assignment-operators-runtime-semantics-evaluation description: Left-hand side as a MemberExpression info: | - AssignmentExpression[In, Yield] : - LeftHandSideExpression[?Yield] = AssignmentExpression[?In, ?Yield] + AssignmentExpression[In, Yield, Await] : + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] 1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, then [...] - e. If IsAnonymousFunctionDefinition(AssignmentExpression) and + c. If IsAnonymousFunctionDefinition(AssignmentExpression) and IsIdentifierRef of LeftHandSideExpression are both true, then - - i. Let hasNameProperty be HasOwnProperty(rval, "name"). - ii. ReturnIfAbrupt(hasNameProperty). - iii. If hasNameProperty is false, perform SetFunctionName(rval, - GetReferencedName(lref)). + i. Let rval be NamedEvaluation of AssignmentExpression with argument + GetReferencedName(lref). +includes: [propertyHelper.js] ---*/ var o = {}; o.attr = function() {}; -assert.sameValue(Object.hasOwnProperty.call(o.attr, 'name'), false); +verifyProperty(o.attr, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/expressions/async-arrow-function/name.js b/test/language/expressions/async-arrow-function/name.js new file mode 100644 index 00000000000..981512d64e3 --- /dev/null +++ b/test/language/expressions/async-arrow-function/name.js @@ -0,0 +1,35 @@ +// Copyright (C) 2019 André Bargull. 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: Assignment of function `name` attribute +info: | + AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody + + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let parameters be AsyncArrowBindingIdentifier. + 3. Let closure be ! AsyncFunctionCreate(Arrow, parameters, AsyncConciseBody, + scope, ""). + ... + 5. Return closure. + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let head be CoveredAsyncArrowHead of CoverCallExpressionAndAsyncArrowHead. + 3. Let parameters be the ArrowFormalParameters of head. + 4. Let closure be ! AsyncFunctionCreate(Arrow, parameters, AsyncConciseBody, + scope, ""). + ... + 6. Return closure. +includes: [propertyHelper.js] +---*/ + +verifyProperty(async x => {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); + +verifyProperty(async () => {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/expressions/async-function/name.js b/test/language/expressions/async-function/name.js new file mode 100644 index 00000000000..1684f86a35c --- /dev/null +++ b/test/language/expressions/async-function/name.js @@ -0,0 +1,36 @@ +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-async-function-definitions-runtime-semantics-evaluation +description: Assignment of function `name` attribute +info: | + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let closure be ! AsyncFunctionCreate(Normal, FormalParameters, + AsyncFunctionBody, scope, ""). + ... + 4. Return closure. + + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + 1. Let scope be the running execution context's LexicalEnvironment. + 2. Let funcEnv be ! NewDeclarativeEnvironment(scope). + 3. Let envRec be funcEnv's EnvironmentRecord. + 4. Let name be StringValue of BindingIdentifier. + 5. Perform ! envRec.CreateImmutableBinding(name). + 6. Let closure be ! AsyncFunctionCreate(Normal, FormalParameters, + AsyncFunctionBody, funcEnv, name). + ... + 9. Return closure. +includes: [propertyHelper.js] +---*/ + +verifyProperty(async function() {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); + +verifyProperty(async function func() {}, "name", { + value: "func", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/expressions/async-generator/name.js b/test/language/expressions/async-generator/name.js new file mode 100644 index 00000000000..d42296e85cf --- /dev/null +++ b/test/language/expressions/async-generator/name.js @@ -0,0 +1,36 @@ +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-asyncgenerator-definitions-evaluation +description: Assignment of function `name` attribute +info: | + AsyncGeneratorExpression : async function * ( FormalParameters ) { AsyncGeneratorBody } + + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, scope, ""). + ... + 6. Return closure. + + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + 1. Let scope be the running execution context's LexicalEnvironment. + 2. Let funcEnv be ! NewDeclarativeEnvironment(scope). + 3. Let envRec be funcEnv's EnvironmentRecord. + 4. Let name be StringValue of BindingIdentifier. + 5. Perform ! envRec.CreateImmutableBinding(name). + 6. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, + AsyncGeneratorBody, funcEnv, name). + ... + 11. Return closure. +includes: [propertyHelper.js] +---*/ + +verifyProperty(async function*() {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); + +verifyProperty(async function* func() {}, "name", { + value: "func", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/expressions/class/name.js b/test/language/expressions/class/name.js index ba0066162dd..c6b3f04aa49 100644 --- a/test/language/expressions/class/name.js +++ b/test/language/expressions/class/name.js @@ -2,31 +2,53 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.5.16 +esid: sec-class-definitions-runtime-semantics-evaluation description: Assignment of function `name` attribute info: | - ClassExpression : class BindingIdentifieropt ClassTail + ClassExpression : class ClassTail + + 1. Let value be ? ClassDefinitionEvaluation of ClassTail with arguments + undefined and "". + ... + 4. Return value. + + ClassExpression : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be ? ClassDefinitionEvaluation of ClassTail with arguments + className and className. + ... + 4. Return value. + + 14.6.13 Runtime Semantics: ClassDefinitionEvaluation + + ... + 12. Let constructorInfo be DefineMethod of constructor with arguments proto, + className as the optional name argument, and constructorParent. + ... + + 14.3.7 Runtime Semantics: DefineMethod + + ... + 7. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, + scope, name, prototype). + ... - 5. If className is not undefined, then - a. Let hasNameProperty be HasOwnProperty(value, "name"). - b. ReturnIfAbrupt(hasNameProperty). - c. If hasNameProperty is false, then - i. Perform SetFunctionName(value, className). includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.hasOwnProperty.call(class {}, 'name'), false); +verifyProperty(class {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); -assert.sameValue(class cls {}.name, 'cls'); -verifyNotEnumerable(class cls {}, 'name'); -verifyNotWritable(class cls {}, 'name'); -verifyConfigurable(class cls {}, 'name'); +verifyProperty(class cls {}, "name", { + value: "cls", writable: false, enumerable: false, configurable: true +}); -assert.sameValue( - Object.hasOwnProperty.call(class { constructor() {} }, 'name'), false -); +verifyProperty(class { constructor() {} }, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); -assert.sameValue(class cls { constructor() {} }.name, 'cls'); -verifyNotEnumerable(class cls { constructor() {} }, 'name'); -verifyNotWritable(class cls { constructor() {} }, 'name'); -verifyConfigurable(class cls { constructor() {} }, 'name'); +verifyProperty(class cls { constructor() {} }, "name", { + value: "cls", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/expressions/function/name.js b/test/language/expressions/function/name.js index 81fd836c4fa..3bf11301362 100644 --- a/test/language/expressions/function/name.js +++ b/test/language/expressions/function/name.js @@ -2,32 +2,35 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.1.20 +esid: sec-function-definitions-runtime-semantics-evaluation description: Assignment of function `name` attribute info: | FunctionExpression : function ( FormalParameters ) { FunctionBody } - 1. If the function code for FunctionExpression is strict mode code, let - strict be true. Otherwise let strict be false. - 2. Let scope be the LexicalEnvironment of the running execution context. - 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, - scope, strict). - 4. Perform MakeConstructor(closure). + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, ""). + ... 5. Return closure. - FunctionExpression : - function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } - [...] - 5. Let name be StringValue of BindingIdentifier. - [...] - 9. Perform SetFunctionName(closure, name). + 1. Let scope be the running execution context's LexicalEnvironment. + 2. Let funcEnv be NewDeclarativeEnvironment(scope). + 3. Let envRec be funcEnv's EnvironmentRecord. + 4. Let name be StringValue of BindingIdentifier. + 5. Perform envRec.CreateImmutableBinding(name, false). + 6. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + funcEnv, name). + ... + 10. Return closure. includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.hasOwnProperty.call(function() {}, 'name'), false); +verifyProperty(function() {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); -assert.sameValue(function func() {}.name, 'func'); -verifyNotEnumerable(function func() {}, 'name'); -verifyNotWritable(function func() {}, 'name'); -verifyConfigurable(function func() {}, 'name'); +verifyProperty(function func() {}, "name", { + value: "func", writable: false, enumerable: false, configurable: true +}); diff --git a/test/language/expressions/generators/name.js b/test/language/expressions/generators/name.js index a652eb6d65c..d5dd11b8507 100644 --- a/test/language/expressions/generators/name.js +++ b/test/language/expressions/generators/name.js @@ -2,31 +2,36 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.4.1 +esid: sec-generator-function-definitions-runtime-semantics-evaluation description: Assignment of function `name` attribute info: | GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } - 1. If the function code for this GeneratorExpression is strict mode code, - let strict be true. Otherwise let strict be false. - 2. Let scope be the LexicalEnvironment of the running execution context. - 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, - GeneratorBody, scope, strict). - 4. Let prototype be ObjectCreate(%GeneratorPrototype%). - 5. Perform MakeConstructor(closure, true, prototype). + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, ""). + ... 6. Return closure. GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } - [...] - 10. Perform SetFunctionName(closure, name). + 1. Let scope be the running execution context's LexicalEnvironment. + 2. Let funcEnv be NewDeclarativeEnvironment(scope). + 3. Let envRec be funcEnv's EnvironmentRecord. + 4. Let name be StringValue of BindingIdentifier. + 5. Perform envRec.CreateImmutableBinding(name, false). + 6. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, funcEnv, name). + ... + 11. Return closure. includes: [propertyHelper.js] features: [generators] ---*/ -assert.sameValue(Object.hasOwnProperty.call(function*() {}, 'name'), false); +verifyProperty(function*() {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); -assert.sameValue(function* func() {}.name, 'func'); -verifyNotEnumerable(function* func() {}, 'name'); -verifyNotWritable(function* func() {}, 'name'); -verifyConfigurable(function* func() {}, 'name'); +verifyProperty(function* func() {}, "name", { + value: "func", writable: false, enumerable: false, configurable: true +});