| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
es6id: 12.14.4 |
| 6 |
description: Assignment of function `name` attribute (ClassExpression) |
| 7 |
info: | |
| 8 |
AssignmentExpression[In, Yield] : |
| 9 |
LeftHandSideExpression[?Yield] = AssignmentExpression[?In, ?Yield] |
| 10 |
|
| 11 |
1. If LeftHandSideExpression is neither an ObjectLiteral nor an |
| 12 |
ArrayLiteral, then |
| 13 |
[...] |
| 14 |
e. If IsAnonymousFunctionDefinition(AssignmentExpression) and |
| 15 |
IsIdentifierRef of LeftHandSideExpression are both true, then |
| 16 |
|
| 17 |
i. Let hasNameProperty be HasOwnProperty(rval, "name"). |
| 18 |
ii. ReturnIfAbrupt(hasNameProperty). |
| 19 |
iii. If hasNameProperty is false, perform SetFunctionName(rval, |
| 20 |
GetReferencedName(lref)). |
| 21 |
includes: [propertyHelper.js] |
| 22 |
features: [class] |
| 23 |
---*/ |
| 24 |
|
| 25 |
var xCls, cls, xCls2; |
| 26 |
|
| 27 |
xCls = class x {}; |
| 28 |
cls = class {}; |
| 29 |
xCls2 = class { static name() {} }; |
| 30 |
|
| 31 |
assert.notSameValue(xCls.name, 'xCls'); |
| 32 |
assert.notSameValue(xCls2.name, 'xCls2'); |
| 33 |
|
| 34 |
assert.sameValue(cls.name, 'cls'); |
| 35 |
verifyNotEnumerable(cls, 'name'); |
| 36 |
verifyNotWritable(cls, 'name'); |
| 37 |
verifyConfigurable(cls, 'name'); |