initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / ecma_2 / Exceptions / string-001.js
1 /**
2     File Name:          string-001.js
3     Corresponds To:     15.5.4.2-2-n.js
4     ECMA Section:       15.5.4.2 String.prototype.toString()
5
6     Description:        Returns this string value.  Note that, for a String
7                         object, the toString() method happens to return the same
8                         thing as the valueOf() method.
9
10                         The toString function is not generic; it generates a
11                         runtime error if its this value is not a String object.
12                         Therefore it connot be transferred to the other kinds of
13                         objects for use as a method.
14
15     Author:             christine@netscape.com
16     Date:               1 october 1997
17 */
18     var SECTION = "string-001";
19     var VERSION = "JS1_4";
20     var TITLE   = "String.prototype.toString";
21
22     startTest();
23     writeHeaderToLog( SECTION + " "+ TITLE);
24
25     var tc = 0;
26     var testcases = new Array();
27
28     var result = "Failed";
29     var exception = "No exception thrown";
30     var expect = "Passed";
31
32     try {
33         OBJECT = new Object();
34         OBJECT.toString = String.prototype.toString();
35         result = OBJECT.toString();
36     } catch ( e ) {
37         result = expect;
38         exception = e.toString();
39     }
40
41     testcases[tc++] = new TestCase(
42         SECTION,
43         "OBJECT = new Object; "+
44         " OBJECT.toString = String.prototype.toString; OBJECT.toString()" +
45         " (threw " + exception +")",
46         expect,
47         result );
48
49     test();
50