summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/jaeger/testPropCallElem.js
blob: 2bb97fbe64a1ca22b459669765f1b6e1250dd6f9 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// vim: set ts=8 sts=4 et sw=4 tw=99:

function testUKeyUObject(a, key1, key2, key3) {
    a.a = function () { return this.d; }
    a.b = function () { return this.e; }
    a.c = function() { return this.f; }
    a.d = 20;
    a.e = "hi";
    a.f = 500;
    assertEq(a[key1](), 20);
    assertEq(a[key2](), "hi");
    assertEq(a[key3](), 500);
}

function testVKeyUObject(a, key1, key2, key3) {
    a.a = function () { return this.d; }
    a.b = function () { return this.e; }
    a.c = function() { return this.f; }
    a.d = 20;
    a.e = "hi";
    a.f = 500;
    assertEq(a["" + key1](), 20);
    assertEq(a["" + key2](), "hi");
    assertEq(a["" + key3](), 500);
}

function testKKeyUObject(a) {
    a.a = function () { return this.d; }
    a.b = function () { return this.e; }
    a.c = function() { return this.f; }
    a.d = 20;
    a.e = "hi";
    a.f = 500;
    var key1 = "a";
    var key2 = "b";
    var key3 = "c";
    assertEq(a[key1](), 20);
    assertEq(a[key2](), "hi");
    assertEq(a[key3](), 500);
}

function testUKeyVObject(key1, key2, key3) {
    a = { a: function () { return this.d; },
          b: function () { return this.e; },
          c: function () { return this.f; },
          d: 20,
          e: "hi",
          f: 500
    };
    assertEq(a[key1](), 20);
    assertEq(a[key2](), "hi");
    assertEq(a[key3](), 500);
}

function testVKeyVObject(key1, key2, key3) {
    a = { a: function () { return this.d; },
          b: function () { return this.e; },
          c: function () { return this.f; },
          d: 20,
          e: "hi",
          f: 500
    };
    assertEq(a["" + key1](), 20);
    assertEq(a["" + key2](), "hi");
    assertEq(a["" + key3](), 500);
}

function testKKeyVObject(a) {
    a = { a: function () { return this.d; },
          b: function () { return this.e; },
          c: function () { return this.f; },
          d: 20,
          e: "hi",
          f: 500
    };
    var key1 = "a";
    var key2 = "b";
    var key3 = "c";
    assertEq(a[key1](), 20);
    assertEq(a[key2](), "hi");
    assertEq(a[key3](), 500);
}

for (var i = 0; i < 5; i++) {
    testUKeyUObject({}, "a", "b", "c");
    testVKeyUObject({}, "a", "b", "c");
    testKKeyUObject({});
    testUKeyVObject("a", "b", "c");
    testVKeyVObject("a", "b", "c");
    testKKeyVObject();
}