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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial