js/src/jit-test/tests/ion/bindname.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 // Test the scope chain walk.
     2 function test1() {
     3     var x = 0;
     4     function f1(addprop) {
     5         function f2() {
     6             eval("");
     7             function f3() {
     8                 eval("");
     9                 function f4() {
    10                     for (var i=0; i<100; i++) {
    11                         x = x + i;
    12                     }
    13                 }
    14                 return f4;
    15             }
    16             return f3();
    17         }
    18         var g = f2();
    19         g();
    20         if (addprop)
    21             eval("var a1 = 3; var x = 33;");
    22         g();
    23         if (addprop)
    24             assertEq(x, 4983);
    25         return f2();
    26     }
    28     var g = f1(true);
    29     g();
    30     g = f1(false);
    31     eval("var y = 2020; var z = y + 3;");
    32     g();
    33     return x;
    34 }
    35 assertEq(test1(), 19800);
    37 // Test with non-cacheable objects on the scope chain.
    38 function test2(o) {
    39     var x = 0;
    40     with ({}) {
    41         with (o) {
    42             var f = function() {
    43                 for (var i=0; i<100; i++) {
    44                     x++;
    45                 }
    46             };
    47         }
    48     }
    49     f();
    50     assertEq(o.x, 110);
    51     assertEq(x, 0);
    52 }
    53 test2({x: 10});

mercurial