js/src/jit-test/tests/pic/callname-global1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/pic/callname-global1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +// Check that the implicit-this logic needed for CALLNAME global stubs
     1.5 +// handles non-function values correctly.
     1.6 +var self = this;
     1.7 +var count = 0;
     1.8 +function g1() {
     1.9 +    assertEq(this, self);
    1.10 +    this.count++;
    1.11 +}
    1.12 +function g2() {
    1.13 +    this.count += 10;
    1.14 +}
    1.15 +function f() {
    1.16 +    function f1(other) {
    1.17 +        eval("gc(); h = g1");
    1.18 +        try {
    1.19 +            for(var i=0; i<20; i++) {
    1.20 +                h();
    1.21 +                if (i === 9) {
    1.22 +                    h = other;
    1.23 +                }
    1.24 +            }
    1.25 +            assertEq(typeof other, "function");
    1.26 +        } catch(e) {
    1.27 +            assertEq(typeof other !== "function", true);
    1.28 +            assertEq(e instanceof TypeError, true);
    1.29 +        }
    1.30 +    }
    1.31 +    f1(3);
    1.32 +    f1(null);
    1.33 +    f1({});
    1.34 +    f1(Math.abs);
    1.35 +    f1(g2);
    1.36 +}
    1.37 +f();
    1.38 +assertEq(count, 150);

mercurial