1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Expressions/11.2.2-2-n.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 11.2.2-2.js 1.12 + ECMA Section: 11.2.2. The new operator 1.13 + Description: 1.14 + 1.15 + MemberExpression: 1.16 + PrimaryExpression 1.17 + MemberExpression[Expression] 1.18 + MemberExpression.Identifier 1.19 + new MemberExpression Arguments 1.20 + 1.21 + new NewExpression 1.22 + 1.23 + The production NewExpression : new NewExpression is evaluated as follows: 1.24 + 1.25 + 1. Evaluate NewExpression. 1.26 + 2. Call GetValue(Result(1)). 1.27 + 3. If Type(Result(2)) is not Object, generate a runtime error. 1.28 + 4. If Result(2) does not implement the internal [[Construct]] method, 1.29 + generate a runtime error. 1.30 + 5. Call the [[Construct]] method on Result(2), providing no arguments 1.31 + (that is, an empty list of arguments). 1.32 + 6. If Type(Result(5)) is not Object, generate a runtime error. 1.33 + 7. Return Result(5). 1.34 + 1.35 + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1.36 + 1.37 + 1. Evaluate MemberExpression. 1.38 + 2. Call GetValue(Result(1)). 1.39 + 3. Evaluate Arguments, producing an internal list of argument values 1.40 + (section 0). 1.41 + 4. If Type(Result(2)) is not Object, generate a runtime error. 1.42 + 5. If Result(2) does not implement the internal [[Construct]] method, 1.43 + generate a runtime error. 1.44 + 6. Call the [[Construct]] method on Result(2), providing the list 1.45 + Result(3) as the argument values. 1.46 + 7. If Type(Result(6)) is not Object, generate a runtime error. 1.47 + 8 .Return Result(6). 1.48 + 1.49 + Author: christine@netscape.com 1.50 + Date: 12 november 1997 1.51 +*/ 1.52 + 1.53 +var SECTION = "11.2.2-2-n.js"; 1.54 +var VERSION = "ECMA_1"; 1.55 +startTest(); 1.56 +var TITLE = "The new operator"; 1.57 + 1.58 +writeHeaderToLog( SECTION + " "+ TITLE); 1.59 + 1.60 +var UNDEFINED = void 0; 1.61 + 1.62 +DESCRIPTION = "UNDEFINED = void 0; var o = new UNDEFINED()"; 1.63 +EXPECTED = "error"; 1.64 + 1.65 +new TestCase( SECTION, 1.66 + "UNDEFINED = void 0; var o = new UNDEFINED()", 1.67 + "error", 1.68 + eval("o = new UNDEFINED()") ); 1.69 +test(); 1.70 + 1.71 +function TestFunction() { 1.72 + return arguments; 1.73 +}