|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * Being in anonymous code, "this" and eval("this"), called as a constructor, return the object |
|
6 * |
|
7 * @path ch11/11.1/11.1.1/S11.1.1_A4.2.js |
|
8 * @description Creating function by using new Function() constructor. It has the property, which returns "this" |
|
9 */ |
|
10 |
|
11 //CHECK#1 |
|
12 var MyFunction = new Function("this.THIS = this"); |
|
13 var MyObject = new MyFunction(); |
|
14 if (MyObject.THIS.toString() !== "[object Object]") { |
|
15 $ERROR('#1: var MyFunction = new Function("this.THIS = this"); var MyObject = new MyFunction(); MyObject.THIS.toString() === "[object Object]". Actual: ' + (MyObject.THIS.toString())); |
|
16 } |
|
17 |
|
18 //CHECK#2 |
|
19 MyFunction = new Function("this.THIS = eval(\'this\')"); |
|
20 MyObject = new MyFunction(); |
|
21 if (MyObject.THIS.toString() !== "[object Object]") { |
|
22 $ERROR('#2: var MyFunction = new Function("this.THIS = eval(\'this\')"); var MyObject = new MyFunction(); MyObject.THIS.toString() === "[object Object]". Actual: ' + (MyObject.THIS.toString())); |
|
23 } |
|
24 |
|
25 |