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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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`"
);

View File

@ -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`"
);

View File

@ -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]),

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.
/*---
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
});

View File

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

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.
/*---
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
});

View File

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

View File

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