Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/computed-property-names/class/static/method-number.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 number
7 includes: [compareArray.js]
8 ---*/
9 class C {
10 static a() { return 'A'; }
11 static [1]() { return 'B'; }
12 static c() { return 'C'; }
13 static [2]() { return 'D'; }
14 }
15 assert.sameValue(C.a(), 'A', "`C.a()` returns `'A'`. Defined as `static a() { return 'A'; }`");
16 assert.sameValue(C[1](), 'B', "`C[1]()` returns `'B'`. Defined as `static [1]() { return 'B'; }`");
17 assert.sameValue(C.c(), 'C', "`C.c()` returns `'C'`. Defined as `static c() { return 'C'; }`");
18 assert.sameValue(C[2](), 'D', "`C[2]()` returns `'D'`. Defined as `static [2]() { return 'D'; }`");
19 assert(
20 compareArray(Object.keys(C), []),
21 "`compareArray(Object.keys(C), [])` returns `true`"
22 );
23 assert(
24 compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'a', 'c', 'name']),
25 "`compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'a', 'c', 'name'])` returns `true`"
26 );