S13.2.2_A12.js (1160B)
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 info: | 6 Calling a function as a constructor is possible as long as 7 this.any_Function is declared and called 8 es5id: 13.2.2_A12 9 description: > 10 Calling a function as a constructor after it has been declared 11 with "function func()" 12 ---*/ 13 14 function FACTORY(){ 15 this.id = 0; 16 17 this.id = func(); 18 19 function func(){ 20 return "id_string"; 21 } 22 23 } 24 ////////////////////////////////////////////////////////////////////////////// 25 //CHECK#1 26 try { 27 var obj = new FACTORY(); 28 } catch (e) { 29 throw new Test262Error('#1: var obj = new FACTORY() does not lead to throwing exception. Actual: Exception is '+e); 30 } 31 // 32 ////////////////////////////////////////////////////////////////////////////// 33 34 ////////////////////////////////////////////////////////////////////////////// 35 //CHECK#2 36 if (obj.id !== "id_string") { 37 throw new Test262Error('#2: obj.id === "id_string". Actual: obj.id ==='+obj.id); 38 } 39 // 40 ////////////////////////////////////////////////////////////////////////////// 41 42 reportCompare(0, 0);