S15.5.1.1_A1_T9.js (1087B)
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 When String is called as a function rather than as a constructor, it 7 performs a type conversion 8 es5id: 15.5.1.1_A1_T9 9 description: Call String(this) 10 ---*/ 11 12 var toString = function() { 13 return "__THIS__"; 14 }; 15 16 var __str = String(this); 17 18 ////////////////////////////////////////////////////////////////////////////// 19 //CHECK#1 20 if (typeof __str !== "string") { 21 throw new Test262Error('#1: __str = String(this); typeof __str === "string". Actual: typeof __str ===' + typeof __str); 22 } 23 // 24 ////////////////////////////////////////////////////////////////////////////// 25 26 ////////////////////////////////////////////////////////////////////////////// 27 //CHECK#2 28 if (__str !== "__THIS__") { 29 throw new Test262Error('#2: toString=function(){return "__THIS__";}; __str = String(this); __str === "__THIS__". Actual: __str ===' + __str); 30 } 31 // 32 ////////////////////////////////////////////////////////////////////////////// 33 34 reportCompare(0, 0);