| 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 | gTestfile = '11.2.2-7-n.js'; |
| 7 | |
| 8 | /** |
| 9 | File Name: 11.2.2-6-n.js |
| 10 | ECMA Section: 11.2.2. The new operator |
| 11 | Description: |
| 12 | |
| 13 | MemberExpression: |
| 14 | PrimaryExpression |
| 15 | MemberExpression[Expression] |
| 16 | MemberExpression.Identifier |
| 17 | new MemberExpression Arguments |
| 18 | |
| 19 | new NewExpression |
| 20 | |
| 21 | The production NewExpression : new NewExpression is evaluated as follows: |
| 22 | |
| 23 | 1. Evaluate NewExpression. |
| 24 | 2. Call GetValue(Result(1)). |
| 25 | 3. If Type(Result(2)) is not Object, generate a runtime error. |
| 26 | 4. If Result(2) does not implement the internal [[Construct]] method, |
| 27 | generate a runtime error. |
| 28 | 5. Call the [[Construct]] method on Result(2), providing no arguments |
| 29 | (that is, an empty list of arguments). |
| 30 | 6. If Type(Result(5)) is not Object, generate a runtime error. |
| 31 | 7. Return Result(5). |
| 32 | |
| 33 | The production MemberExpression : new MemberExpression Arguments is evaluated as follows: |
| 34 | |
| 35 | 1. Evaluate MemberExpression. |
| 36 | 2. Call GetValue(Result(1)). |
| 37 | 3. Evaluate Arguments, producing an internal list of argument values |
| 38 | (section 0). |
| 39 | 4. If Type(Result(2)) is not Object, generate a runtime error. |
| 40 | 5. If Result(2) does not implement the internal [[Construct]] method, |
| 41 | generate a runtime error. |
| 42 | 6. Call the [[Construct]] method on Result(2), providing the list |
| 43 | Result(3) as the argument values. |
| 44 | 7. If Type(Result(6)) is not Object, generate a runtime error. |
| 45 | 8 .Return Result(6). |
| 46 | |
| 47 | Author: [email protected] |
| 48 | Date: 12 november 1997 |
| 49 | */ |
| 50 | |
| 51 | var SECTION = "11.2.2-6-n.js"; |
| 52 | var VERSION = "ECMA_1"; |
| 53 | startTest(); |
| 54 | var TITLE = "The new operator"; |
| 55 | |
| 56 | writeHeaderToLog( SECTION + " "+ TITLE); |
| 57 | |
| 58 | var STRING = new String("hi"); |
| 59 | |
| 60 | DESCRIPTION = "var STRING = new String('hi'); var s = new STRING()"; |
| 61 | EXPECTED = "error"; |
| 62 | |
| 63 | new TestCase( SECTION, |
| 64 | "var STRING = new String('hi'); var s = new STRING()", |
| 65 | "error", |
| 66 | eval("s = new STRING()") ); |
| 67 | test(); |
| 68 | |
| 69 | function TestFunction() { |
| 70 | return arguments; |
| 71 | } |