Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/computed-property-names/class/accessor/getter-duplicates.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, duplicate computed property getter names produce only a single property of
7 that name, whose value is the value of the last property of that name.
8 ---*/
9 class C {
10 get ['a']() {
11 return 'A';
12 }
13 }
14 assert.sameValue(new C().a, 'A', "The value of `new C().a` is `'A'`");
15
16 class C2 {
17 get b() {
18 $ERROR("The first `b` getter definition in `C2` is unreachable");
19 }
20 get ['b']() {
21 return 'B';
22 }
23 }
24 assert.sameValue(new C2().b, 'B', "The value of `new C2().b` is `'B'`");
25
26 class C3 {
27 get c() {
28 $ERROR("The first `c` getter definition in `C3` is unreachable");
29 }
30 get ['c']() {
31 $ERROR("The second `c` getter definition in `C3` is unreachable");
32 }
33 get ['c']() {
34 return 'C';
35 }
36 }
37 assert.sameValue(new C3().c, 'C', "The value of `new C3().c` is `'C'`");
38
39 class C4 {
40 get ['d']() {
41 $ERROR("The first `d` getter definition in `C4` is unreachable");
42 }
43 get d() {
44 return 'D';
45 }
46 }
47 assert.sameValue(new C4().d, 'D', "The value of `new C4().d` is `'D'`");