]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/Exceptions/boolean-001.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma_2 / Exceptions / boolean-001.js
1 /**
2 File Name: boolean-001.js
3 Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js
4
5 The toString function is not generic; it generates
6 a runtime error if its this value is not a Boolean
7 object. Therefore it cannot be transferred to other
8 kinds of objects for use as a method.
9
10 Author: christine@netscape.com
11 Date: june 27, 1997
12 */
13 var SECTION = "boolean-001.js";
14 var VERSION = "JS1_4";
15 var TITLE = "Boolean.prototype.toString()";
16 startTest();
17 writeHeaderToLog( SECTION +" "+ TITLE );
18
19 var tc = 0;
20 var testcases = new Array();
21
22 var exception = "No exception thrown";
23 var result = "Failed";
24
25 var TO_STRING = Boolean.prototype.toString;
26
27 try {
28 var s = new String("Not a Boolean");
29 s.toString = TO_STRING;
30 s.toString();
31 } catch ( e ) {
32 result = "Passed!";
33 exception = e.toString();
34 }
35
36 testcases[tc++] = new TestCase(
37 SECTION,
38 "Assigning Boolean.prototype.toString to a String object "+
39 "(threw " +exception +")",
40 "Passed!",
41 result );
42
43 test();