js/src/tests/ecma/Expressions/11.2.3-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Expressions/11.2.3-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     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.3-1.js
    1.12 +   ECMA Section:       11.2.3. Function Calls
    1.13 +   Description:
    1.14 +
    1.15 +   The production CallExpression : MemberExpression Arguments is evaluated as
    1.16 +   follows:
    1.17 +
    1.18 +   1.Evaluate MemberExpression.
    1.19 +   2.Evaluate Arguments, producing an internal list of argument values
    1.20 +   (section 0).
    1.21 +   3.Call GetValue(Result(1)).
    1.22 +   4.If Type(Result(3)) is not Object, generate a runtime error.
    1.23 +   5.If Result(3) does not implement the internal [[Call]] method, generate a
    1.24 +   runtime error.
    1.25 +   6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise,
    1.26 +   Result(6) is null.
    1.27 +   7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is
    1.28 +   the same as Result(6).
    1.29 +   8.Call the [[Call]] method on Result(3), providing Result(7) as the this value
    1.30 +   and providing the list Result(2) as the argument values.
    1.31 +   9.Return Result(8).
    1.32 +
    1.33 +   The production CallExpression : CallExpression Arguments is evaluated in
    1.34 +   exactly the same manner, except that the contained CallExpression is
    1.35 +   evaluated in step 1.
    1.36 +
    1.37 +   Note: Result(8) will never be of type Reference if Result(3) is a native
    1.38 +   ECMAScript object. Whether calling a host object can return a value of
    1.39 +   type Reference is implementation-dependent.
    1.40 +
    1.41 +   Author:             christine@netscape.com
    1.42 +   Date:               12 november 1997
    1.43 +*/
    1.44 +
    1.45 +var SECTION = "11.2.3-1";
    1.46 +var VERSION = "ECMA_1";
    1.47 +startTest();
    1.48 +var TITLE   = "Function Calls";
    1.49 +
    1.50 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.51 +
    1.52 +/*  this.eval() is no longer legal syntax.
    1.53 +// MemberExpression : this
    1.54 +
    1.55 +new TestCase( SECTION,
    1.56 +"this.eval()",
    1.57 +void 0,
    1.58 +this.eval() );
    1.59 +
    1.60 +new TestCase( SECTION,
    1.61 +"this.eval('NaN')",
    1.62 +NaN,
    1.63 +this.eval("NaN") );
    1.64 +*/
    1.65 +// MemberExpression:  Identifier
    1.66 +
    1.67 +var OBJECT = true;
    1.68 +
    1.69 +new TestCase( SECTION,
    1.70 +              "OBJECT.toString()",
    1.71 +              "true",
    1.72 +              OBJECT.toString() );
    1.73 +
    1.74 +// MemberExpression[ Expression]
    1.75 +
    1.76 +new TestCase( SECTION,
    1.77 +              "(new Array())['length'].valueOf()",
    1.78 +              0,
    1.79 +              (new Array())["length"].valueOf() );
    1.80 +
    1.81 +// MemberExpression . Identifier
    1.82 +new TestCase( SECTION,
    1.83 +              "(new Array()).length.valueOf()",
    1.84 +              0,
    1.85 +              (new Array()).length.valueOf() );
    1.86 +// new MemberExpression Arguments
    1.87 +
    1.88 +new TestCase( SECTION,
    1.89 +              "(new Array(20))['length'].valueOf()",
    1.90 +              20,
    1.91 +              (new Array(20))["length"].valueOf() );
    1.92 +
    1.93 +test();
    1.94 +

mercurial