Debian Codegraph @

js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T13.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_T13
9 description: >
10 Creating string object with "new String(function object)" after
11 changing function object's valueOf property, which causes
12 exception throw
13 ---*/
14
15 var __obj = {
16 toString: function() {
17 return f;
18
19 function f() {}
20 }
21 };
22
23 __obj.valueOf = function() {
24 throw "invalueof"
25 };
26
27 //////////////////////////////////////////////////////////////////////////////
28 //CHECK#1
29 try {
30 var __str = new String(__obj);
31 throw new Test262Error('#1: __obj.valueOf=function(){throw "invalueof"}; __str = new String(__obj) lead throwing exception');
32 } catch (e) {
33 if (e !== "invalueof") {
34 throw new Test262Error('#1.1: e==="invalueof". Actual: e===' + e);
35 }
36 }
37 //
38 //////////////////////////////////////////////////////////////////////////////
39
40 reportCompare(0, 0);