Debian Codegraph @

js/src/tests/test262/built-ins/String/S8.12.8_A1.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 This should generate a TypeError,
7 Cause we overload toString method so it return non Primitive value
8 See ECMA reference at http://bugzilla.mozilla.org/show_bug.cgi?id=167325
9 es5id: 8.12.8_A1
10 description: Try to overload toString method
11 ---*/
12
13 try
14 {
15 var __obj = {
16 toString: function() {
17 return new Object();
18 }
19 }
20 String(__obj);
21 throw new Test262Error('#1.1: var __obj = {toString: function() {return new Object();}}; String(__obj) throw TypeError. Actual: ' + (String(__obj)));
22 }
23 catch (e)
24 {
25 if ((e instanceof TypeError) !== true) {
26 throw new Test262Error('#1.2: var __obj = {toString: function() {return new Object();}}; String(__obj) throw TypeError. Actual: ' + (e));
27 }
28 }
29
30 reportCompare(0, 0);