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