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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // Check that the implicit-this logic needed for CALLNAME global stubs
     2 // handles non-function values correctly.
     3 var self = this;
     4 var count = 0;
     5 function g1() {
     6     assertEq(this, self);
     7     this.count++;
     8 }
     9 function g2() {
    10     this.count += 10;
    11 }
    12 function f() {
    13     function f1(other) {
    14         eval("gc(); h = g1");
    15         try {
    16             for(var i=0; i<20; i++) {
    17                 h();
    18                 if (i === 9) {
    19                     h = other;
    20                 }
    21             }
    22             assertEq(typeof other, "function");
    23         } catch(e) {
    24             assertEq(typeof other !== "function", true);
    25             assertEq(e instanceof TypeError, true);
    26         }
    27     }
    28     f1(3);
    29     f1(null);
    30     f1({});
    31     f1(Math.abs);
    32     f1(g2);
    33 }
    34 f();
    35 assertEq(count, 150);

mercurial