summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/computed-property-names/class/accessor/setter-duplicates.js
blob: f42801874ea98259d7054ca1ffda63a6cd41a6dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
    In a class, duplicate computed property setter names produce only a single property of
    that name, whose value is the value of the last property of that name.
---*/
var calls = 0;
class C {
  set ['a'](_) {
    calls++;
  }
}
new C().a = 'A';
assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `new C().a = 'A';`");

calls = 0;
class C2 {
  set b(_) {
    throw new Test262Error("The first `b` setter definition in `C2` is unreachable");
  }
  set ['b'](_) {
    calls++;
  }
}
new C2().b = 'B';
assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `new C2().b = 'B';`");

calls = 0;
class C3 {
  set c(_) {
    throw new Test262Error("The first `c` setter definition in `C3` is unreachable");
  }
  set ['c'](_) {
    throw new Test262Error("The second `c` setter definition in `C3` is unreachable");
  }
  set ['c'](_) {
    calls++
  }
}
new C3().c = 'C';
assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `new C3().c = 'C';`");

calls = 0;
class C4 {
  set ['d'](_) {
    throw new Test262Error("The first `d` setter definition in `C4` is unreachable");
  }
  set d(_) {
    calls++
  }
}
new C4().d = 'D';
assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `new C4().d = 'D';`");

reportCompare(0, 0);