js/src/jit-test/tests/jaeger/testPropCallElem.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/jaeger/testPropCallElem.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +// vim: set ts=8 sts=4 et sw=4 tw=99:
     1.5 +
     1.6 +function testUKeyUObject(a, key1, key2, key3) {
     1.7 +    a.a = function () { return this.d; }
     1.8 +    a.b = function () { return this.e; }
     1.9 +    a.c = function() { return this.f; }
    1.10 +    a.d = 20;
    1.11 +    a.e = "hi";
    1.12 +    a.f = 500;
    1.13 +    assertEq(a[key1](), 20);
    1.14 +    assertEq(a[key2](), "hi");
    1.15 +    assertEq(a[key3](), 500);
    1.16 +}
    1.17 +
    1.18 +function testVKeyUObject(a, key1, key2, key3) {
    1.19 +    a.a = function () { return this.d; }
    1.20 +    a.b = function () { return this.e; }
    1.21 +    a.c = function() { return this.f; }
    1.22 +    a.d = 20;
    1.23 +    a.e = "hi";
    1.24 +    a.f = 500;
    1.25 +    assertEq(a["" + key1](), 20);
    1.26 +    assertEq(a["" + key2](), "hi");
    1.27 +    assertEq(a["" + key3](), 500);
    1.28 +}
    1.29 +
    1.30 +function testKKeyUObject(a) {
    1.31 +    a.a = function () { return this.d; }
    1.32 +    a.b = function () { return this.e; }
    1.33 +    a.c = function() { return this.f; }
    1.34 +    a.d = 20;
    1.35 +    a.e = "hi";
    1.36 +    a.f = 500;
    1.37 +    var key1 = "a";
    1.38 +    var key2 = "b";
    1.39 +    var key3 = "c";
    1.40 +    assertEq(a[key1](), 20);
    1.41 +    assertEq(a[key2](), "hi");
    1.42 +    assertEq(a[key3](), 500);
    1.43 +}
    1.44 +
    1.45 +function testUKeyVObject(key1, key2, key3) {
    1.46 +    a = { a: function () { return this.d; },
    1.47 +          b: function () { return this.e; },
    1.48 +          c: function () { return this.f; },
    1.49 +          d: 20,
    1.50 +          e: "hi",
    1.51 +          f: 500
    1.52 +    };
    1.53 +    assertEq(a[key1](), 20);
    1.54 +    assertEq(a[key2](), "hi");
    1.55 +    assertEq(a[key3](), 500);
    1.56 +}
    1.57 +
    1.58 +function testVKeyVObject(key1, key2, key3) {
    1.59 +    a = { a: function () { return this.d; },
    1.60 +          b: function () { return this.e; },
    1.61 +          c: function () { return this.f; },
    1.62 +          d: 20,
    1.63 +          e: "hi",
    1.64 +          f: 500
    1.65 +    };
    1.66 +    assertEq(a["" + key1](), 20);
    1.67 +    assertEq(a["" + key2](), "hi");
    1.68 +    assertEq(a["" + key3](), 500);
    1.69 +}
    1.70 +
    1.71 +function testKKeyVObject(a) {
    1.72 +    a = { a: function () { return this.d; },
    1.73 +          b: function () { return this.e; },
    1.74 +          c: function () { return this.f; },
    1.75 +          d: 20,
    1.76 +          e: "hi",
    1.77 +          f: 500
    1.78 +    };
    1.79 +    var key1 = "a";
    1.80 +    var key2 = "b";
    1.81 +    var key3 = "c";
    1.82 +    assertEq(a[key1](), 20);
    1.83 +    assertEq(a[key2](), "hi");
    1.84 +    assertEq(a[key3](), 500);
    1.85 +}
    1.86 +
    1.87 +for (var i = 0; i < 5; i++) {
    1.88 +    testUKeyUObject({}, "a", "b", "c");
    1.89 +    testVKeyUObject({}, "a", "b", "c");
    1.90 +    testKKeyUObject({});
    1.91 +    testUKeyVObject("a", "b", "c");
    1.92 +    testVKeyVObject("a", "b", "c");
    1.93 +    testKKeyVObject();
    1.94 +}
    1.95 +
    1.96 +

mercurial