2011-09-07 08:35:18 +02:00
|
|
|
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
2014-07-22 01:09:02 +02:00
|
|
|
/*---
|
2018-01-05 18:26:51 +01:00
|
|
|
info: |
|
2014-07-22 01:09:02 +02:00
|
|
|
We overload valueOf method so it return non Primitive value and toString method so it return non Primitive value too
|
|
|
|
Thus [[DefaultValue]] must generate TypeError error
|
2014-07-25 00:41:42 +02:00
|
|
|
es5id: 8.12.8_A4
|
2014-07-22 01:09:02 +02:00
|
|
|
description: >
|
|
|
|
Try to overload toString and valueOf methods, they returned new
|
|
|
|
Objects
|
|
|
|
---*/
|
2011-09-07 08:35:18 +02:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2018-02-15 21:11:50 +01:00
|
|
|
var __obj = {
|
|
|
|
valueOf: function() {
|
|
|
|
return new Object;
|
|
|
|
},
|
|
|
|
toString: function() {
|
|
|
|
return new Object();
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 08:35:18 +02:00
|
|
|
Number(__obj);
|
2021-07-21 23:25:53 +02:00
|
|
|
throw new Test262Error('#1.1: var __obj = {valueOf:function(){return new Object;},toNumber: function() {return new Object();}}; Number(__obj) throw TypeError. Actual: ' + (Number(__obj)));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
2018-02-15 21:11:50 +01:00
|
|
|
catch (e)
|
2011-09-07 08:35:18 +02:00
|
|
|
{
|
2021-08-11 22:08:22 +02:00
|
|
|
assert.sameValue(
|
|
|
|
e instanceof TypeError,
|
|
|
|
true,
|
|
|
|
'The result of evaluating (e instanceof TypeError) is expected to be true'
|
|
|
|
);
|
2014-07-22 01:09:02 +02:00
|
|
|
}
|