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

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