S8.12.8_A4.js (975B)
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 We overload valueOf method so it return non Primitive value and toString method so it return non Primitive value too 7 Thus [[DefaultValue]] must generate TypeError error 8 es5id: 8.12.8_A4 9 description: > 10 Try to overload toString and valueOf methods, they returned new 11 Objects 12 ---*/ 13 14 try 15 { 16 var __obj = { 17 valueOf: function() { 18 return new Object; 19 }, 20 toString: function() { 21 return new Object(); 22 } 23 } 24 Number(__obj); 25 throw new Test262Error('#1.1: var __obj = {valueOf:function(){return new Object;},toNumber: function() {return new Object();}}; Number(__obj) throw TypeError. Actual: ' + (Number(__obj))); 26 } 27 catch (e) 28 { 29 assert.sameValue( 30 e instanceof TypeError, 31 true, 32 'The result of evaluating (e instanceof TypeError) is expected to be true' 33 ); 34 } 35 36 reportCompare(0, 0);