]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/mozilla/ecma/Expressions/11.2.3-1.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma / Expressions / 11.2.3-1.js
CommitLineData
b37bf2e1
A
1/* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
5 *
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
23 File Name: 11.2.3-1.js
24 ECMA Section: 11.2.3. Function Calls
25 Description:
26
27 The production CallExpression : MemberExpression Arguments is evaluated as
28 follows:
29
30 1.Evaluate MemberExpression.
31 2.Evaluate Arguments, producing an internal list of argument values
32 (section 0).
33 3.Call GetValue(Result(1)).
34 4.If Type(Result(3)) is not Object, generate a runtime error.
35 5.If Result(3) does not implement the internal [[Call]] method, generate a
36 runtime error.
37 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise,
38 Result(6) is null.
39 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is
40 the same as Result(6).
41 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value
42 and providing the list Result(2) as the argument values.
43 9.Return Result(8).
44
45 The production CallExpression : CallExpression Arguments is evaluated in
46 exactly the same manner, except that the contained CallExpression is
47 evaluated in step 1.
48
49 Note: Result(8) will never be of type Reference if Result(3) is a native
50 ECMAScript object. Whether calling a host object can return a value of
51 type Reference is implementation-dependent.
52
53 Author: christine@netscape.com
54 Date: 12 november 1997
55*/
56
57 var SECTION = "11.2.3-1";
58 var VERSION = "ECMA_1";
59 startTest();
60 var TITLE = "Function Calls";
61
62 writeHeaderToLog( SECTION + " "+ TITLE);
63
64 var testcases = new Array();
65
66/* this.eval() is no longer legal syntax.
67 // MemberExpression : this
68
69 testcases[tc++] = new TestCase( SECTION,
70 "this.eval()",
71 void 0,
72 this.eval() );
73
74 testcases[tc++] = new TestCase( SECTION,
75 "this.eval('NaN')",
76 NaN,
77 this.eval("NaN") );
78*/
79 // MemberExpression: Identifier
80
81 var OBJECT = true;
82
83 testcases[tc++] = new TestCase( SECTION,
84 "OBJECT.toString()",
85 "true",
86 OBJECT.toString() );
87
88 // MemberExpression[ Expression]
89
90 testcases[tc++] = new TestCase( SECTION,
91 "(new Array())['length'].valueOf()",
92 0,
93 (new Array())["length"].valueOf() );
94
95 // MemberExpression . Identifier
96 testcases[tc++] = new TestCase( SECTION,
97 "(new Array()).length.valueOf()",
98 0,
99 (new Array()).length.valueOf() );
100 // new MemberExpression Arguments
101
102 testcases[tc++] = new TestCase( SECTION,
103 "(new Array(20))['length'].valueOf()",
104 20,
105 (new Array(20))["length"].valueOf() );
106
107 test();
108
109function test() {
110 for ( tc=0; tc < testcases.length; tc++ ) {
111 testcases[tc].passed = writeTestCaseResult(
112 testcases[tc].expect,
113 testcases[tc].actual,
114 testcases[tc].description +" = "+
115 testcases[tc].actual );
116
117 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
118 }
119 stopTest();
120 return ( testcases );
121}