this-binding-with-eval.js (878B)
1 function Test1() { 2 this.x = 8; 3 this.y = 5; 4 this.z = 2; 5 var o = {".this": {x: 1}}; 6 var res; 7 with (o) { 8 res = this.x + (() => this.z)() + eval("this.x + (() => this.y)()"); 9 } 10 assertEq(res, 23); 11 } 12 new Test1(); 13 14 function Test2() { 15 this.x = 8; 16 var o = {".this": {x: 1}}; 17 with (o) { 18 return eval("() => this.x"); 19 } 20 } 21 var fun = new Test2(); 22 assertEq(fun(), 8); 23 24 function Test3() { 25 this.x = 8; 26 var o = {".this": {x: 1}}; 27 with (o) { 28 assertEq(this.x, 8); 29 } 30 } 31 new Test3(); 32 33 function test4() { 34 var o = {".this": {x: 1}}; 35 with (o) { 36 return () => this; 37 } 38 } 39 assertEq(test4()(), this); 40 41 function test5() { 42 var o = {".this": {x: 1}}; 43 with (o) { 44 return this; 45 } 46 } 47 assertEq(test5(), this); 48 49 var global = this; 50 evaluate("with({}) { assertEq(this, global); }"); 51 eval("with({}) { assertEq(this, global); }");