initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / js1_3 / Script / new-001.js
1 /* The contents of this file are subject to the Netscape Public
2  * License Version 1.1 (the "License"); you may not use this file
3  * except in compliance with the License. You may obtain a copy of
4  * the License at http://www.mozilla.org/NPL/
5  *
6  * Software distributed under the License is distributed on an "AS
7  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8  * implied. See the License for the specific language governing
9  * rights and limitations under the License.
10  *
11  * The Original Code is Mozilla Communicator client code, released March
12  * 31, 1998.
13  *
14  * The Initial Developer of the Original Code is Netscape Communications
15  * Corporation. Portions created by Netscape are
16  * Copyright (C) 1998 Netscape Communications Corporation. All
17  * Rights Reserved.
18  *
19  * Contributor(s): 
20  * 
21  */
22 /**
23     File Name:          new-001.js
24     Section:
25     Description:
26
27     http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103
28
29     Author:             christine@netscape.com
30     Date:               12 november 1997
31 */
32     var SECTION = "new-001";
33     var VERSION = "JS1_3";
34     var TITLE   = "new-001";
35     var BUGNUMBER="31567";
36
37     startTest();
38     writeHeaderToLog( SECTION + " "+ TITLE);
39
40     var testcases = new Array();
41
42     function Test_One (x) {
43         this.v = x+1;
44         return x*2
45     }
46
47     function Test_Two( x, y ) {
48         this.v = x;
49         return y;
50     }
51
52     testcases[tc++] = new TestCase(
53         SECTION,
54         "Test_One(18)",
55         36,
56         Test_One(18) );
57
58     testcases[tc++] = new TestCase(
59         SECTION,
60         "new Test_One(18)",
61         "[object Object]",
62         new Test_One(18) +"" );
63
64     testcases[tc++] = new TestCase(
65         SECTION,
66         "new Test_One(18).v",
67         19,
68         new Test_One(18).v );
69
70     testcases[tc++] = new TestCase(
71         SECTION,
72         "Test_Two(2,7)",
73         7,
74         Test_Two(2,7) );
75
76     testcases[tc++] = new TestCase(
77         SECTION,
78         "new Test_Two(2,7)",
79         "[object Object]",
80         new Test_Two(2,7) +"" );
81
82     testcases[tc++] = new TestCase(
83         SECTION,
84         "new Test_Two(2,7).v",
85         2,
86         new Test_Two(2,7).v );
87
88     testcases[tc++] = new TestCase(
89         SECTION,
90         "new (Function)(\"x\", \"return x+3\")(5,6)",
91         8,
92         new (Function)("x","return x+3")(5,6) );
93
94     testcases[tc++] = new TestCase(
95         SECTION,
96         "new new Test_Two(String, 2).v(0123)",
97         "83",
98         new new Test_Two(String, 2).v(0123) +"");
99
100     testcases[tc++] = new TestCase(
101         SECTION,
102         "new new Test_Two(String, 2).v(0123).length",
103         2,
104         new new Test_Two(String, 2).v(0123).length );
105
106     test();
107
108 function test() {
109     for ( tc=0; tc < testcases.length; tc++ ) {
110         testcases[tc].passed = writeTestCaseResult(
111                             testcases[tc].expect,
112                             testcases[tc].actual,
113                             testcases[tc].description +" = "+
114                             testcases[tc].actual );
115
116         testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
117     }
118     stopTest();
119     return ( testcases );
120 }