michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * Being in anonymous code, "this" and eval("this"), called as a constructor, return the object michael@0: * michael@0: * @path ch11/11.1/11.1.1/S11.1.1_A4.2.js michael@0: * @description Creating function by using new Function() constructor. It has the property, which returns "this" michael@0: */ michael@0: michael@0: //CHECK#1 michael@0: var MyFunction = new Function("this.THIS = this"); michael@0: var MyObject = new MyFunction(); michael@0: if (MyObject.THIS.toString() !== "[object Object]") { michael@0: $ERROR('#1: var MyFunction = new Function("this.THIS = this"); var MyObject = new MyFunction(); MyObject.THIS.toString() === "[object Object]". Actual: ' + (MyObject.THIS.toString())); michael@0: } michael@0: michael@0: //CHECK#2 michael@0: MyFunction = new Function("this.THIS = eval(\'this\')"); michael@0: MyObject = new MyFunction(); michael@0: if (MyObject.THIS.toString() !== "[object Object]") { michael@0: $ERROR('#2: var MyFunction = new Function("this.THIS = eval(\'this\')"); var MyObject = new MyFunction(); MyObject.THIS.toString() === "[object Object]". Actual: ' + (MyObject.THIS.toString())); michael@0: } michael@0: michael@0: