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