js/src/jit-test/tests/ion/setgname.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/ion/setgname.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +
     1.5 +// aaa is initially undefined. Make sure it's set to the
     1.6 +// correct value - we have to store the type tag, even though
     1.7 +// its known type is int32.
     1.8 +var aaa;
     1.9 +function f() {
    1.10 +    function g(x) {
    1.11 +        if (x)
    1.12 +            aaa = 22;
    1.13 +    }
    1.14 +    g(10);
    1.15 +
    1.16 +    function h() {
    1.17 +        aaa = 22;
    1.18 +    }
    1.19 +    for (var i=0; i<70; i++) {
    1.20 +        h();
    1.21 +    }
    1.22 +    assertEq(aaa, 22);
    1.23 +}
    1.24 +f();
    1.25 +
    1.26 +x = 0;
    1.27 +function setX(i) {
    1.28 +    x = i;
    1.29 +}
    1.30 +for (var i=0; i<70; i++)
    1.31 +    setX(i);
    1.32 +assertEq(x, 69);
    1.33 +
    1.34 +y = 3.14;
    1.35 +y = true;
    1.36 +y = [];
    1.37 +function setY(arg) {
    1.38 +    y = arg;
    1.39 +}
    1.40 +for (var i=0; i<70; i++)
    1.41 +    setY([1]);
    1.42 +setY([1, 2, 3]);
    1.43 +assertEq(y.length, 3);
    1.44 +
    1.45 +// z is non-configurable, but can be made non-writable.
    1.46 +var z = 10;
    1.47 +
    1.48 +function testNonWritable() {
    1.49 +    function g() {
    1.50 +        z = 11;
    1.51 +    }
    1.52 +    for (var i=0; i<70; i++) {
    1.53 +        g();
    1.54 +    }
    1.55 +    Object.defineProperty(this, "z", {value: 1234, writable: false});
    1.56 +    g();
    1.57 +    assertEq(z, 1234);
    1.58 +}
    1.59 +testNonWritable();

mercurial