Debian Codegraph @

rhino/testsrc/tests/ecma_2/Exceptions/string-002.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-002.js';
7
8 /**
9 File Name: string-002.js
10 Corresponds To: 15.5.4.3-3-n.js
11 ECMA Section: 15.5.4.3 String.prototype.valueOf()
12
13 Description: Returns this string value.
14
15 The valueOf function is not generic; it generates a
16 runtime error if its this value is not a String object.
17 Therefore it connot be transferred to the other kinds of
18 objects for use as a method.
19
20 Author: [email protected]
21 Date: 1 october 1997
22 */
23 var SECTION = "string-002";
24 var VERSION = "JS1_4";
25 var TITLE = "String.prototype.valueOf";
26
27 startTest();
28 writeHeaderToLog( SECTION + " "+ TITLE);
29
30 var result = "Failed";
31 var exception = "No exception thrown";
32 var expect = "Passed";
33
34 try {
35 var OBJECT =new Object();
36 OBJECT.valueOf = String.prototype.valueOf;
37 result = OBJECT.valueOf();
38 } catch ( e ) {
39 result = expect;
40 exception = e.toString();
41 }
42
43 new TestCase(
44 SECTION,
45 "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+
46 "result = OBJECT.valueOf();" +
47 " (threw " + exception +")",
48 expect,
49 result );
50
51 test();
52
53