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
|
|
|
When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and
|
|
|
|
The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied
|
2014-07-25 00:41:42 +02:00
|
|
|
es5id: 15.5.2.1_A1_T13
|
2014-07-22 01:09:02 +02:00
|
|
|
description: >
|
|
|
|
Creating string object with "new String(function object)" after
|
|
|
|
changing function object's valueOf property, which causes
|
|
|
|
exception throw
|
|
|
|
---*/
|
2011-09-07 08:35:18 +02:00
|
|
|
|
2018-02-09 18:09:47 +01:00
|
|
|
var __obj = {toString:function(){return f; function f(){}}};
|
2011-09-07 08:35:18 +02:00
|
|
|
|
2018-02-09 18:09:47 +01:00
|
|
|
__obj.valueOf=function(){throw "invalueof"};
|
2011-09-07 08:35:18 +02:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//CHECK#1
|
|
|
|
try {
|
|
|
|
var __str = new String(__obj);
|
|
|
|
$ERROR('#1: __obj.valueOf=function(){throw "invalueof"}; __str = new String(__obj) lead throwing exception');
|
|
|
|
} catch (e) {
|
2018-02-09 18:09:47 +01:00
|
|
|
if (e!=="invalueof") {
|
|
|
|
$ERROR('#1.1: e==="invalueof". Actual: e==='+e);
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|