michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 11.2.2-1.js michael@0: ECMA Section: 11.2.2. The new operator michael@0: Description: michael@0: michael@0: MemberExpression: michael@0: PrimaryExpression michael@0: MemberExpression[Expression] michael@0: MemberExpression.Identifier michael@0: new MemberExpression Arguments michael@0: michael@0: new NewExpression michael@0: michael@0: The production NewExpression : new NewExpression is evaluated as follows: michael@0: michael@0: 1. Evaluate NewExpression. michael@0: 2. Call GetValue(Result(1)). michael@0: 3. If Type(Result(2)) is not Object, generate a runtime error. michael@0: 4. If Result(2) does not implement the internal [[Construct]] method, michael@0: generate a runtime error. michael@0: 5. Call the [[Construct]] method on Result(2), providing no arguments michael@0: (that is, an empty list of arguments). michael@0: 6. If Type(Result(5)) is not Object, generate a runtime error. michael@0: 7. Return Result(5). michael@0: michael@0: The production MemberExpression : new MemberExpression Arguments is evaluated as follows: michael@0: michael@0: 1. Evaluate MemberExpression. michael@0: 2. Call GetValue(Result(1)). michael@0: 3. Evaluate Arguments, producing an internal list of argument values michael@0: (section 0). michael@0: 4. If Type(Result(2)) is not Object, generate a runtime error. michael@0: 5. If Result(2) does not implement the internal [[Construct]] method, michael@0: generate a runtime error. michael@0: 6. Call the [[Construct]] method on Result(2), providing the list michael@0: Result(3) as the argument values. michael@0: 7. If Type(Result(6)) is not Object, generate a runtime error. michael@0: 8 .Return Result(6). michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 12 november 1997 michael@0: */ michael@0: michael@0: var SECTION = "11.2.2-1"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "The new operator"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, michael@0: "(new TestFunction(0,1,2,3,4,5)).length", michael@0: 6, michael@0: (new TestFunction(0,1,2,3,4,5)).length ); michael@0: michael@0: test(); michael@0: michael@0: function TestFunction() { michael@0: return arguments; michael@0: }