summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/fields/field_types.js
blob: f93991c3214eef5d2fcac30df16c163148cd7c5b (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
class C {
    [Math.sqrt(16)];
    [Math.sqrt(8)] = 5 + 2;
    "hi";
    "bye" = {};
    2 = 2;
    0x101 = 2;
    0o101 = 2;
    0b101 = 2;
    NaN = 0; // actually the field called "NaN", not the number
    Infinity = 50; // actually the field called "Infinity", not the number
    // all the keywords below are proper fields (?!?)
    with = 0;
    //static = 0; // doesn't work yet
    async = 0;
    get = 0;
    set = 0;
    export = 0;
    function = 0;
}

let obj = new C();
assertEq(Math.sqrt(16) in obj, true);
assertEq(obj[Math.sqrt(16)], undefined);
assertEq(obj[Math.sqrt(8)], 7);
assertEq("hi" in obj, true);
assertEq(obj["hi"], undefined);
assertEq(typeof obj["bye"], "object");
assertEq(obj[2], 2);
assertEq(obj[0x101], 2);
assertEq(obj[0o101], 2);
assertEq(obj[0b101], 2);
assertEq(obj.NaN, 0);
assertEq(obj.Infinity, 50);
assertEq(obj.with, 0);
assertEq(obj.async, 0);
assertEq(obj.get, 0);
assertEq(obj.set, 0);
assertEq(obj.export, 0);
assertEq(obj.function, 0);

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