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