Assign "name" property to all anonymous functions (#2299)

Implements the changes from <https://github.com/tc39/ecma262/pull/1490>.
This commit is contained in:
André Bargull 2019-08-15 07:58:40 -07:00 committed by Leo Balter
parent 40dca6ef33
commit 59a1a016b7
23 changed files with 373 additions and 145 deletions

View File

@ -8,9 +8,14 @@ info: |
A promise resolve function is an anonymous built-in function. A promise resolve function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects: 17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not Every built-in function object, including constructors, has a `name`
identified as an anonymous function has a name property whose value property whose value is a String. Functions that are identified as
is a String. 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; var resolveElementFunction;
@ -28,5 +33,6 @@ NotPromise.resolve = function(v) {
}; };
Promise.all.call(NotPromise, [thenable]); Promise.all.call(NotPromise, [thenable]);
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, "name"), false); verifyProperty(resolveElementFunction, "name", {
assert.sameValue(resolveElementFunction.name, ""); value: "", writable: false, enumerable: false, configurable: true
});

View File

@ -8,9 +8,14 @@ info: |
A promise resolve function is an anonymous built-in function. A promise resolve function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects: 17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not Every built-in function object, including constructors, has a `name`
identified as an anonymous function has a name property whose value property whose value is a String. Functions that are identified as
is a String. 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] features: [Promise.allSettled]
---*/ ---*/
@ -29,5 +34,6 @@ NotPromise.resolve = function(v) {
}; };
Promise.allSettled.call(NotPromise, [thenable]); Promise.allSettled.call(NotPromise, [thenable]);
assert.sameValue(Object.prototype.hasOwnProperty.call(rejectElementFunction, 'name'), false); verifyProperty(rejectElementFunction, "name", {
assert.sameValue(rejectElementFunction.name, ''); value: "", writable: false, enumerable: false, configurable: true
});

View File

@ -8,9 +8,14 @@ info: |
A promise resolve function is an anonymous built-in function. A promise resolve function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects: 17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not Every built-in function object, including constructors, has a `name`
identified as an anonymous function has a name property whose value property whose value is a String. Functions that are identified as
is a String. 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] features: [Promise.allSettled]
---*/ ---*/
@ -29,8 +34,6 @@ NotPromise.resolve = function(v) {
}; };
Promise.allSettled.call(NotPromise, [thenable]); Promise.allSettled.call(NotPromise, [thenable]);
assert.sameValue( verifyProperty(resolveElementFunction, "name", {
Object.prototype.hasOwnProperty.call(resolveElementFunction, 'name'), value: "", writable: false, enumerable: false, configurable: true
false });
);
assert.sameValue(resolveElementFunction.name, '');

View File

@ -8,9 +8,14 @@ info: |
A GetCapabilitiesExecutor function is an anonymous built-in function. A GetCapabilitiesExecutor function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects: 17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not Every built-in function object, including constructors, has a `name`
identified as an anonymous function has a name property whose value property whose value is a String. Functions that are identified as
is a String. 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; var executorFunction;
@ -21,5 +26,6 @@ function NotPromise(executor) {
} }
Promise.resolve.call(NotPromise); Promise.resolve.call(NotPromise);
assert.sameValue(Object.prototype.hasOwnProperty.call(executorFunction, "name"), false); verifyProperty(executorFunction, "name", {
assert.sameValue(executorFunction.name, ""); value: "", writable: false, enumerable: false, configurable: true
});

View File

@ -8,9 +8,14 @@ info: |
A promise reject function is an anonymous built-in function. A promise reject function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects: 17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not Every built-in function object, including constructors, has a `name`
identified as an anonymous function has a name property whose value property whose value is a String. Functions that are identified as
is a String. 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; var rejectFunction;
@ -18,5 +23,6 @@ new Promise(function(resolve, reject) {
rejectFunction = reject; rejectFunction = reject;
}); });
assert.sameValue(Object.prototype.hasOwnProperty.call(rejectFunction, "name"), false); verifyProperty(rejectFunction, "name", {
assert.sameValue(rejectFunction.name, ""); value: "", writable: false, enumerable: false, configurable: true
});

View File

@ -8,9 +8,14 @@ info: |
A promise resolve function is an anonymous built-in function. A promise resolve function is an anonymous built-in function.
17 ECMAScript Standard Built-in Objects: 17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not Every built-in function object, including constructors, has a `name`
identified as an anonymous function has a name property whose value property whose value is a String. Functions that are identified as
is a String. 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; var resolveFunction;
@ -18,5 +23,6 @@ new Promise(function(resolve, reject) {
resolveFunction = resolve; resolveFunction = resolve;
}); });
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveFunction, "name"), false); verifyProperty(resolveFunction, "name", {
assert.sameValue(resolveFunction.name, ""); value: "", writable: false, enumerable: false, configurable: true
});

View File

@ -8,12 +8,19 @@ info: |
A Proxy revocation function is an anonymous function. A Proxy revocation function is an anonymous function.
17 ECMAScript Standard Built-in Objects: 17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not Every built-in function object, including constructors, has a `name`
identified as an anonymous function has a name property whose value property whose value is a String. Functions that are identified as
is a String. 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] features: [Proxy]
---*/ ---*/
var revocationFunction = Proxy.revocable({}, {}).revoke; var revocationFunction = Proxy.revocable({}, {}).revoke;
assert.sameValue(Object.prototype.hasOwnProperty.call(revocationFunction, "name"), false); verifyProperty(revocationFunction, "name", {
value: "", writable: false, enumerable: false, configurable: true
});

View File

@ -8,8 +8,21 @@ description: >
info: | info: |
%ThrowTypeError% ( ) %ThrowTypeError% ( )
The %ThrowTypeError% intrinsic is an anonymous built-in function 9.2.9.1 %ThrowTypeError% ( )
object that is defined once for each Realm. 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() { var ThrowTypeError = Object.getOwnPropertyDescriptor(function() {
@ -17,4 +30,6 @@ var ThrowTypeError = Object.getOwnPropertyDescriptor(function() {
return arguments; return arguments;
}(), "callee").get; }(), "callee").get;
assert.sameValue(Object.prototype.hasOwnProperty.call(ThrowTypeError, "name"), false); verifyProperty(ThrowTypeError, "name", {
value: "", writable: false, enumerable: false, configurable: false
});

View File

@ -8,15 +8,19 @@ description: >
info: | info: |
10.3.3 get Intl.Collator.prototype.compare 10.3.3 get Intl.Collator.prototype.compare
... 17 ECMAScript Standard Built-in Objects:
4. If collator.[[boundCompare]] is undefined, then Every built-in function object, including constructors, has a `name`
a. Let F be a new built-in function object as defined in 10.3.4. property whose value is a String. Functions that are identified as
b. Let bc be BoundFunctionCreate(F, collator, « »). anonymous functions use the empty string as the value of the `name`
c. Perform ! DefinePropertyOrThrow(bc, "length", PropertyDescriptor {[[Value]]: 2, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). property.
d. Set collator.[[boundCompare]] to bc. 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; 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
});

View File

@ -8,15 +8,19 @@ description: >
info: | info: |
12.4.3 get Intl.DateTimeFormat.prototype.compare 12.4.3 get Intl.DateTimeFormat.prototype.compare
... 17 ECMAScript Standard Built-in Objects:
4. If the [[boundFormat]] internal slot of dtf is undefined, then Every built-in function object, including constructors, has a `name`
a. Let F be a new built-in function object as defined in DateTime Format Functions (12.1.5). property whose value is a String. Functions that are identified as
b. Let bf be BoundFunctionCreate(F, dft, « »). anonymous functions use the empty string as the value of the `name`
c. Perform ! DefinePropertyOrThrow(bf, "length", PropertyDescriptor {[[Value]]: 1, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). property.
d. Set dtf.[[boundFormat]] to bf. 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; 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
});

View File

@ -8,15 +8,19 @@ description: >
info: | info: |
11.4.3 get Intl.NumberFormat.prototype.compare 11.4.3 get Intl.NumberFormat.prototype.compare
... 17 ECMAScript Standard Built-in Objects:
4. If nf.[[boundFormat]] is undefined, then Every built-in function object, including constructors, has a `name`
a. Let F be a new built-in function object as defined in Number Format Functions (11.1.3). property whose value is a String. Functions that are identified as
b. Let bf be BoundFunctionCreate(F, nf, « »). anonymous functions use the empty string as the value of the `name`
c. Perform ! DefinePropertyOrThrow(bf, "length", PropertyDescriptor {[[Value]]: 1, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). property.
d. Set nf.[[boundFormat]] to bf. 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; 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
});

View File

@ -1,7 +1,7 @@
// Copyright (C) 2014 the V8 project authors. All rights reserved. // Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 12.2.5 esid: sec-object-initializer
description: > description: >
In a class, static computed property method names can be a number In a class, static computed property method names can be a number
includes: [compareArray.js] includes: [compareArray.js]
@ -21,6 +21,6 @@ assert(
"`compareArray(Object.keys(C), [])` returns `true`" "`compareArray(Object.keys(C), [])` returns `true`"
); );
assert( assert(
compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'name', 'a', 'c']), compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'name', 'prototype', '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'])` returns `true`"
); );

View File

@ -1,7 +1,7 @@
// Copyright (C) 2014 the V8 project authors. All rights reserved. // Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 12.2.5 esid: sec-object-initializer
description: > description: >
In a class, static computed property method names can be a string In a class, static computed property method names can be a string
includes: [compareArray.js] includes: [compareArray.js]
@ -21,6 +21,6 @@ assert(
"`compareArray(Object.keys(C), [])` returns `true`" "`compareArray(Object.keys(C), [])` returns `true`"
); );
assert( assert(
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'b', 'c', 'd']), compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype', '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'])` returns `true`"
); );

View File

@ -1,7 +1,7 @@
// Copyright (C) 2014 the V8 project authors. All rights reserved. // Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 12.2.5 esid: sec-object-initializer
description: > description: >
In a class, static computed property method names can be a symbol In a class, static computed property method names can be a symbol
includes: [compareArray.js] includes: [compareArray.js]
@ -24,8 +24,8 @@ assert(
"`compareArray(Object.keys(C), [])` returns `true`" "`compareArray(Object.keys(C), [])` returns `true`"
); );
assert( assert(
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'c']), compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype', 'a', 'c']),
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'c'])` returns `true`" "`compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype', 'a', 'c'])` returns `true`"
); );
assert( assert(
compareArray(Object.getOwnPropertySymbols(C), [sym1, sym2]), compareArray(Object.getOwnPropertySymbols(C), [sym1, sym2]),

View File

@ -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
});

View File

@ -2,26 +2,26 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Left-hand side as a CoverParenthesizedExpression
info: | info: |
AssignmentExpression[In, Yield] : AssignmentExpression[In, Yield, Await] :
LeftHandSideExpression[?Yield] = AssignmentExpression[?In, ?Yield] LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await]
1. If LeftHandSideExpression is neither an ObjectLiteral nor an 1. If LeftHandSideExpression is neither an ObjectLiteral nor an
ArrayLiteral, then ArrayLiteral, then
[...] [...]
e. If IsAnonymousFunctionDefinition(AssignmentExpression) and c. If IsAnonymousFunctionDefinition(AssignmentExpression) and
IsIdentifierRef of LeftHandSideExpression are both true, then IsIdentifierRef of LeftHandSideExpression are both true, then
i. Let rval be NamedEvaluation of AssignmentExpression with argument
i. Let hasNameProperty be HasOwnProperty(rval, "name"). GetReferencedName(lref).
ii. ReturnIfAbrupt(hasNameProperty). includes: [propertyHelper.js]
iii. If hasNameProperty is false, perform SetFunctionName(rval,
GetReferencedName(lref)).
---*/ ---*/
var fn; var fn;
(fn) = function() {}; (fn) = function() {};
assert.sameValue(Object.hasOwnProperty.call(fn, 'name'), false); verifyProperty(fn, "name", {
value: "", writable: false, enumerable: false, configurable: true
});

View File

@ -2,26 +2,26 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Left-hand side as a MemberExpression
info: | info: |
AssignmentExpression[In, Yield] : AssignmentExpression[In, Yield, Await] :
LeftHandSideExpression[?Yield] = AssignmentExpression[?In, ?Yield] LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await]
1. If LeftHandSideExpression is neither an ObjectLiteral nor an 1. If LeftHandSideExpression is neither an ObjectLiteral nor an
ArrayLiteral, then ArrayLiteral, then
[...] [...]
e. If IsAnonymousFunctionDefinition(AssignmentExpression) and c. If IsAnonymousFunctionDefinition(AssignmentExpression) and
IsIdentifierRef of LeftHandSideExpression are both true, then IsIdentifierRef of LeftHandSideExpression are both true, then
i. Let rval be NamedEvaluation of AssignmentExpression with argument
i. Let hasNameProperty be HasOwnProperty(rval, "name"). GetReferencedName(lref).
ii. ReturnIfAbrupt(hasNameProperty). includes: [propertyHelper.js]
iii. If hasNameProperty is false, perform SetFunctionName(rval,
GetReferencedName(lref)).
---*/ ---*/
var o = {}; var o = {};
o.attr = function() {}; o.attr = function() {};
assert.sameValue(Object.hasOwnProperty.call(o.attr, 'name'), false); verifyProperty(o.attr, "name", {
value: "", writable: false, enumerable: false, configurable: true
});

View File

@ -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
});

View File

@ -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
});

View File

@ -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
});

View File

@ -2,31 +2,53 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Assignment of function `name` attribute
info: | 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] 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'); verifyProperty(class cls {}, "name", {
verifyNotEnumerable(class cls {}, 'name'); value: "cls", writable: false, enumerable: false, configurable: true
verifyNotWritable(class cls {}, 'name'); });
verifyConfigurable(class cls {}, 'name');
assert.sameValue( verifyProperty(class { constructor() {} }, "name", {
Object.hasOwnProperty.call(class { constructor() {} }, 'name'), false value: "", writable: false, enumerable: false, configurable: true
); });
assert.sameValue(class cls { constructor() {} }.name, 'cls'); verifyProperty(class cls { constructor() {} }, "name", {
verifyNotEnumerable(class cls { constructor() {} }, 'name'); value: "cls", writable: false, enumerable: false, configurable: true
verifyNotWritable(class cls { constructor() {} }, 'name'); });
verifyConfigurable(class cls { constructor() {} }, 'name');

View File

@ -2,32 +2,35 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Assignment of function `name` attribute
info: | info: |
FunctionExpression : function ( FormalParameters ) { FunctionBody } FunctionExpression : function ( FormalParameters ) { FunctionBody }
1. If the function code for FunctionExpression is strict mode code, let 1. Let scope be the LexicalEnvironment of the running execution context.
strict be true. Otherwise let strict be false. 2. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody,
2. Let scope be the LexicalEnvironment of the running execution context. scope, "").
3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, ...
scope, strict).
4. Perform MakeConstructor(closure).
5. Return closure. 5. Return closure.
FunctionExpression : FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody }
function BindingIdentifier ( FormalParameters ) { FunctionBody }
[...] 1. Let scope be the running execution context's LexicalEnvironment.
5. Let name be StringValue of BindingIdentifier. 2. Let funcEnv be NewDeclarativeEnvironment(scope).
[...] 3. Let envRec be funcEnv's EnvironmentRecord.
9. Perform SetFunctionName(closure, name). 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] 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'); verifyProperty(function func() {}, "name", {
verifyNotEnumerable(function func() {}, 'name'); value: "func", writable: false, enumerable: false, configurable: true
verifyNotWritable(function func() {}, 'name'); });
verifyConfigurable(function func() {}, 'name');

View File

@ -2,31 +2,36 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 description: Assignment of function `name` attribute
info: | info: |
GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } GeneratorExpression : function * ( FormalParameters ) { GeneratorBody }
1. If the function code for this GeneratorExpression is strict mode code, 1. Let scope be the LexicalEnvironment of the running execution context.
let strict be true. Otherwise let strict be false. 2. Let closure be GeneratorFunctionCreate(Normal, FormalParameters,
2. Let scope be the LexicalEnvironment of the running execution context. GeneratorBody, scope, "").
3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, ...
GeneratorBody, scope, strict).
4. Let prototype be ObjectCreate(%GeneratorPrototype%).
5. Perform MakeConstructor(closure, true, prototype).
6. Return closure. 6. Return closure.
GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
[...] 1. Let scope be the running execution context's LexicalEnvironment.
10. Perform SetFunctionName(closure, name). 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] includes: [propertyHelper.js]
features: [generators] 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'); verifyProperty(function* func() {}, "name", {
verifyNotEnumerable(function* func() {}, 'name'); value: "func", writable: false, enumerable: false, configurable: true
verifyNotWritable(function* func() {}, 'name'); });
verifyConfigurable(function* func() {}, 'name');