summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Function/function-name-computed-02.js
blob: 54048aee4972794c2e8d02970fb9922a6011e8af (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
var obj = {
  [1]: function() {},
  [2]: function*() {},
  [3]: async function() {},
  [4]: async function*() {},
  [5]: ()=>{},
  [6]: async ()=>{},
  [7] () {},
  [8]: class {},
  [9]: function F() {},
  [10]: class C{},
  get [11]() {},
  set [12](x) {},
};

assertEq(obj[1].name, "1");
assertEq(obj[2].name, "2");
assertEq(obj[3].name, "3");
assertEq(obj[4].name, "4");
assertEq(obj[5].name, "5");
assertEq(obj[6].name, "6");
assertEq(obj[7].name, "7");
assertEq(obj[8].name, "8");
assertEq(obj[9].name, "F");
assertEq(obj[10].name, "C");
assertEq(Object.getOwnPropertyDescriptor(obj, "11").get.name, "get 11");
assertEq(Object.getOwnPropertyDescriptor(obj, "12").set.name, "set 12");

let dummy = class {
  [1]() {}
  *[2]() {}
  async [3]() {}
  async *[4]() {}
  [5] = ()=>{}
  [6] = async ()=>{};
  [7] () {}
  get [11]() {}
  set [12](x) {}
};

dum = new dummy();

assertEq(dum[1].name, "1");
assertEq(dum[2].name, "2");
assertEq(dum[3].name, "3");
assertEq(dum[4].name, "4");
assertEq(dum[5].name, "5");
assertEq(dum[6].name, "6");
assertEq(dum[7].name, "7");

assertEq(Object.getOwnPropertyDescriptor(dummy.prototype, "11").get.name, "get 11");
assertEq(Object.getOwnPropertyDescriptor(dummy.prototype, "12").set.name, "set 12");


if (typeof reportCompare === "function")
  reportCompare(true, true);