Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/computed-property-names/object/accessor/setter-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 an object, 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 var calls = 0;
10 var A = {
11 set ['a'](_) {
12 calls++;
13 }
14 };
15 A.a = 'A';
16 assert.sameValue(calls, 1, "The value of `calls` is `1`");
17
18 calls = 0;
19 var B = {
20 set b(_) {
21 $ERROR("The `b` setter definition in `B` is unreachable");
22 },
23 set ['b'](_) {
24 calls++;
25 }
26 };
27 B.b = 'B';
28 assert.sameValue(calls, 1, "The value of `calls` is `1`");
29
30 calls = 0;
31 var C = {
32 set c(_) {
33 $ERROR("The `c` setter definition in `C` is unreachable");
34 },
35 set ['c'](_) {
36 $ERROR("The first `['c']` setter definition in `C` is unreachable");
37 },
38 set ['c'](_) {
39 calls++
40 }
41 };
42 C.c = 'C';
43 assert.sameValue(calls, 1, "The value of `calls` is `1`");
44
45 calls = 0;
46 var D = {
47 set ['d'](_) {
48 $ERROR("The `['d']` setter definition in `D` is unreachable");
49 },
50 set d(_) {
51 calls++
52 }
53 };
54 D.d = 'D';
55 assert.sameValue(calls, 1, "The value of `calls` is `1`");