]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Expressions/11.2.2-11.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/
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.
11 * The Original Code is Mozilla Communicator client code, released March
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
23 File Name: 11.2.2-9-n.js
24 ECMA Section: 11.2.2. The new operator
29 MemberExpression[Expression]
30 MemberExpression.Identifier
31 new MemberExpression Arguments
35 The production NewExpression : new NewExpression is evaluated as follows:
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.
47 The production MemberExpression : new MemberExpression Arguments is evaluated as follows:
49 1. Evaluate MemberExpression.
50 2. Call GetValue(Result(1)).
51 3. Evaluate Arguments, producing an internal list of argument values
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.
61 Author: christine@netscape.com
62 Date: 12 november 1997
65 var SECTION
= "11.2.2-9-n.js";
66 var VERSION
= "ECMA_1";
68 var TITLE
= "The new operator";
70 writeHeaderToLog( SECTION
+ " "+ TITLE
);
72 var testcases
= new Array();
74 var FUNCTION
= new Function();
76 testcases
[tc
++] = new TestCase( SECTION
,
77 "var FUNCTION = new Function(); f = new FUNCTION(); typeof f",
79 eval("var FUNCTION = new Function(); f = new FUNCTION(); typeof f") );
81 testcases
[tc
++] = new TestCase( SECTION
,
82 "var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f",
84 eval("var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f") );
88 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
89 testcases
[tc
].passed
= writeTestCaseResult(
92 testcases
[tc
].description
+" = "+
93 testcases
[tc
].actual
);
95 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";