initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / ecma / Expressions / 11.2.2-3-n.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:          11.2.2-3-n.js
24     ECMA Section:       11.2.2. The new operator
25     Description:
26
27     MemberExpression:
28         PrimaryExpression
29         MemberExpression[Expression]
30         MemberExpression.Identifier
31         new MemberExpression Arguments
32
33     new NewExpression
34
35     The production NewExpression : new NewExpression is evaluated as follows:
36
37    1.   Evaluate NewExpression.
38    2.   Call GetValue(Result(1)).
39    3.   If Type(Result(2)) is not Object, generate a runtime error.
40    4.   If Result(2) does not implement the internal [[Construct]] method,
41         generate a runtime error.
42    5.   Call the [[Construct]] method on Result(2), providing no arguments
43         (that is, an empty list of arguments).
44    6.   If Type(Result(5)) is not Object, generate a runtime error.
45    7.   Return Result(5).
46
47     The production MemberExpression : new MemberExpression Arguments is evaluated as follows:
48
49    1.   Evaluate MemberExpression.
50    2.   Call GetValue(Result(1)).
51    3.   Evaluate Arguments, producing an internal list of argument values
52         (section 0).
53    4.   If Type(Result(2)) is not Object, generate a runtime error.
54    5.   If Result(2) does not implement the internal [[Construct]] method,
55         generate a runtime error.
56    6.   Call the [[Construct]] method on Result(2), providing the list
57         Result(3) as the argument values.
58    7.   If Type(Result(6)) is not Object, generate a runtime error.
59    8    .Return Result(6).
60
61     Author:             christine@netscape.com
62     Date:               12 november 1997
63 */
64
65     var SECTION = "11.2.2-3-n.js";
66     var VERSION = "ECMA_1";
67     startTest();
68     var TITLE   = "The new operator";
69
70     writeHeaderToLog( SECTION + " "+ TITLE);
71
72     var testcases = new Array();
73
74
75     var NULL = null;
76
77     testcases[tc++] = new TestCase( SECTION,
78                                     "NULL = null; var o = new NULL()",
79                                     "error",
80                                     o = new NULL() );
81     test();
82
83 function TestFunction() {
84     return arguments;
85 }
86 function test() {
87     for ( tc=0; tc < testcases.length; tc++ ) {
88         testcases[tc].passed = writeTestCaseResult(
89                             testcases[tc].expect,
90                             testcases[tc].actual,
91                             testcases[tc].description +" = "+
92                             testcases[tc].actual );
93
94         testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
95     }
96     stopTest();
97     return ( testcases );
98 }