| 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 |
| 7 |
Thus [[DefaultValue]] must return Object.toString() value |
| 8 |
es5id: 8.12.8_A3 |
| 9 |
description: > |
| 10 |
Try to overload toString method, that returned Primitive, and |
| 11 |
valueOf method, that returned new Object |
| 12 |
---*/ |
| 13 |
|
| 14 |
try |
| 15 |
{ |
| 16 |
var __obj = { |
| 17 |
toString: function() { |
| 18 |
return "1" |
| 19 |
}, |
| 20 |
valueOf: function() { |
| 21 |
return new Object(); |
| 22 |
} |
| 23 |
} |
| 24 |
if (Number(__obj) !== 1) { |
| 25 |
$ERROR('#1.1: var __obj = {toNumber: function() {return "1"}, valueOf: function() {return new Object();}}; Number(__obj) === 1. Actual: ' + (Number(__obj))); |
| 26 |
} |
| 27 |
} |
| 28 |
catch (e) |
| 29 |
{ |
| 30 |
$ERROR('#1.2: var __obj = {toNumber: function() {return "1"}, valueOf: function() {return new Object();}}; Number(__obj) === 1. Actual: ' + (e)); |
| 31 |
} |