Debian Codegraph @

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