Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/object/fn-name-fn.js

raw
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.2.6.9
6 description: Assignment of function `name` attribute (FunctionExpression)
7 info: |
8 6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
9 a. Let hasNameProperty be HasOwnProperty(propValue, "name").
10 b. ReturnIfAbrupt(hasNameProperty).
11 c. If hasNameProperty is false, perform SetFunctionName(propValue,
12 propKey).
13 includes: [propertyHelper.js]
14 features: [Symbol]
15 ---*/
16
17 var namedSym = Symbol('test262');
18 var anonSym = Symbol();
19 var o;
20
21 o = {
22 xId: function x() {},
23 id: function() {},
24 [anonSym]: function() {},
25 [namedSym]: function() {}
26 };
27
28 assert(o.xId.name !== 'xId');
29
30 assert.sameValue(o.id.name, 'id', 'via IdentifierName');
31 verifyNotEnumerable(o.id, 'name');
32 verifyNotWritable(o.id, 'name');
33 verifyConfigurable(o.id, 'name');
34
35 assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol');
36 verifyNotEnumerable(o[anonSym], 'name');
37 verifyNotWritable(o[anonSym], 'name');
38 verifyConfigurable(o[anonSym], 'name');
39
40 assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol');
41 verifyNotEnumerable(o[namedSym], 'name');
42 verifyNotWritable(o[namedSym], 'name');
43 verifyConfigurable(o[namedSym], 'name');