S15.5.1.1_A1_T8.js (1313B)
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_T8 9 description: Call String(new Array) 10 ---*/ 11 12 var __old__Array__prototype__toString = Array.prototype.toString; 13 14 Array.prototype.toString = function() { 15 return "__ARRAY__"; 16 }; 17 18 var __str = String(new Array); 19 20 // restore old toString method just in case 21 Array.prototype.toString = __old__Array__prototype__toString; 22 23 ////////////////////////////////////////////////////////////////////////////// 24 //CHECK#1 25 if (typeof __str !== "string") { 26 throw new Test262Error('#1: __str = String(new Array); typeof __str === "string". Actual: typeof __str ===' + typeof __str); 27 } 28 // 29 ////////////////////////////////////////////////////////////////////////////// 30 31 ////////////////////////////////////////////////////////////////////////////// 32 //CHECK#2 33 if (__str !== "__ARRAY__") { 34 throw new Test262Error('#2: Array.prototype.toString=function(){return "__ARRAY__";}; __str = String(new Array); __str === "__ARRAY__". Actual: __str ===' + __str); 35 } 36 // 37 ////////////////////////////////////////////////////////////////////////////// 38 39 reportCompare(0, 0);