Debian Codegraph @

js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T12.js

raw
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 part of a new expression, it is a constructor: it initialises the newly created object and
7 The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied
8 es5id: 15.5.2.1_A1_T12
9 description: >
10 Creating string object with "new String(function object)", after
11 changing the function object toString property, which causes
12 exception throw
13 ---*/
14
15 var __obj = {
16 toString: function() {
17 throw "intostr"
18 }
19 };
20
21 __obj.valueOf = function() {
22 return true
23 };
24
25 //////////////////////////////////////////////////////////////////////////////
26 //CHECK#1
27 try {
28 var __str = new String(__obj);
29 throw new Test262Error('#1: var __obj = {toString:function(){throw "intostr"}}; __str = new String(__obj) lead throwing exception');
30 } catch (e) {
31 if (e !== "intostr") {
32 throw new Test262Error('#1.1: e==="intostr". Actual: e===' + e);
33 }
34 }
35 //
36 //////////////////////////////////////////////////////////////////////////////
37
38 reportCompare(0, 0);