Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/computed-property-names/class/static/method-symbol.js

raw
1 // Copyright (C) 2014 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 12.2.5
5 description: >
6 In a class, static computed property method names can be a symbol
7 includes: [compareArray.js]
8 features: [Symbol]
9 ---*/
10 var sym1 = Symbol();
11 var sym2 = Symbol();
12 class C {
13 static a() { return 'A'; }
14 static [sym1]() { return 'B'; }
15 static c() { return 'C'; }
16 static [sym2]() { return 'D'; }
17 }
18 assert.sameValue(C.a(), 'A', "`C.a()` returns `'A'`. Defined as `static a() { return 'A'; }`");
19 assert.sameValue(C[sym1](), 'B', "`C[sym1]()` returns `'B'`. Defined as `static [sym1]() { return 'B'; }`");
20 assert.sameValue(C.c(), 'C', "`C.c()` returns `'C'`. Defined as `static c() { return 'C'; }`");
21 assert.sameValue(C[sym2](), 'D', "`C[sym2]()` returns `'D'`. Defined as `static [sym2]() { return 'D'; }`");
22 assert(
23 compareArray(Object.keys(C), []),
24 "`compareArray(Object.keys(C), [])` returns `true`"
25 );
26 assert(
27 compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'c', 'name']),
28 "`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'c', 'name'])` returns `true`"
29 );
30 assert(
31 compareArray(Object.getOwnPropertySymbols(C), [sym1, sym2]),
32 "`compareArray(Object.getOwnPropertySymbols(C), [sym1, sym2])` returns `true`"
33 );