Debian Codegraph @

rhino/testsrc/tests/ecma_2/Exceptions/string-001.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'string-001.js';
7
8 /**
9 File Name: string-001.js
10 Corresponds To: 15.5.4.2-2-n.js
11 ECMA Section: 15.5.4.2 String.prototype.toString()
12
13 Description: Returns this string value. Note that, for a String
14 object, the toString() method happens to return the same
15 thing as the valueOf() method.
16
17 The toString function is not generic; it generates a
18 runtime error if its this value is not a String object.
19 Therefore it connot be transferred to the other kinds of
20 objects for use as a method.
21
22 Author: [email protected]
23 Date: 1 october 1997
24 */
25 var SECTION = "string-001";
26 var VERSION = "JS1_4";
27 var TITLE = "String.prototype.toString";
28
29 startTest();
30 writeHeaderToLog( SECTION + " "+ TITLE);
31
32 var result = "Failed";
33 var exception = "No exception thrown";
34 var expect = "Passed";
35
36 try {
37 OBJECT = new Object();
38 OBJECT.toString = String.prototype.toString();
39 result = OBJECT.toString();
40 } catch ( e ) {
41 result = expect;
42 exception = e.toString();
43 }
44
45 new TestCase(
46 SECTION,
47 "OBJECT = new Object; "+
48 " OBJECT.toString = String.prototype.toString; OBJECT.toString()" +
49 " (threw " + exception +")",
50 expect,
51 result );
52
53 test();
54