|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 File Name: 11.2.2-6-n.js |
|
9 ECMA Section: 11.2.2. The new operator |
|
10 Description: |
|
11 |
|
12 MemberExpression: |
|
13 PrimaryExpression |
|
14 MemberExpression[Expression] |
|
15 MemberExpression.Identifier |
|
16 new MemberExpression Arguments |
|
17 |
|
18 new NewExpression |
|
19 |
|
20 The production NewExpression : new NewExpression is evaluated as follows: |
|
21 |
|
22 1. Evaluate NewExpression. |
|
23 2. Call GetValue(Result(1)). |
|
24 3. If Type(Result(2)) is not Object, generate a runtime error. |
|
25 4. If Result(2) does not implement the internal [[Construct]] method, |
|
26 generate a runtime error. |
|
27 5. Call the [[Construct]] method on Result(2), providing no arguments |
|
28 (that is, an empty list of arguments). |
|
29 6. If Type(Result(5)) is not Object, generate a runtime error. |
|
30 7. Return Result(5). |
|
31 |
|
32 The production MemberExpression : new MemberExpression Arguments is evaluated as follows: |
|
33 |
|
34 1. Evaluate MemberExpression. |
|
35 2. Call GetValue(Result(1)). |
|
36 3. Evaluate Arguments, producing an internal list of argument values |
|
37 (section 0). |
|
38 4. If Type(Result(2)) is not Object, generate a runtime error. |
|
39 5. If Result(2) does not implement the internal [[Construct]] method, |
|
40 generate a runtime error. |
|
41 6. Call the [[Construct]] method on Result(2), providing the list |
|
42 Result(3) as the argument values. |
|
43 7. If Type(Result(6)) is not Object, generate a runtime error. |
|
44 8 .Return Result(6). |
|
45 |
|
46 Author: christine@netscape.com |
|
47 Date: 12 november 1997 |
|
48 */ |
|
49 |
|
50 var SECTION = "11.2.2-6-n.js"; |
|
51 var VERSION = "ECMA_1"; |
|
52 startTest(); |
|
53 var TITLE = "The new operator"; |
|
54 |
|
55 writeHeaderToLog( SECTION + " "+ TITLE); |
|
56 |
|
57 var STRING = new String("hi"); |
|
58 |
|
59 DESCRIPTION = "var STRING = new String('hi'); var s = new STRING()"; |
|
60 EXPECTED = "error"; |
|
61 |
|
62 new TestCase( SECTION, |
|
63 "var STRING = new String('hi'); var s = new STRING()", |
|
64 "error", |
|
65 eval("s = new STRING()") ); |
|
66 test(); |
|
67 |
|
68 function TestFunction() { |
|
69 return arguments; |
|
70 } |