Debian Codegraph @

rhino/testsrc/tests/ecma_2/Exceptions/boolean-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 = 'boolean-001.js';
7
8 /**
9 File Name: boolean-001.js
10 Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js
11
12 The toString function is not generic; it generates
13 a runtime error if its this value is not a Boolean
14 object. Therefore it cannot be transferred to other
15 kinds of objects for use as a method.
16
17 Author: [email protected]
18 Date: june 27, 1997
19 */
20 var SECTION = "boolean-001.js";
21 var VERSION = "JS1_4";
22 var TITLE = "Boolean.prototype.toString()";
23 startTest();
24 writeHeaderToLog( SECTION +" "+ TITLE );
25
26 var exception = "No exception thrown";
27 var result = "Failed";
28
29 var TO_STRING = Boolean.prototype.toString;
30
31 try {
32 var s = new String("Not a Boolean");
33 s.toString = TO_STRING;
34 s.toString();
35 } catch ( e ) {
36 result = "Passed!";
37 exception = e.toString();
38 }
39
40 new TestCase(
41 SECTION,
42 "Assigning Boolean.prototype.toString to a String object "+
43 "(threw " +exception +")",
44 "Passed!",
45 result );
46
47 test();
48