|
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 |
|
7 /** |
|
8 File Name: 11.2.3-1.js |
|
9 ECMA Section: 11.2.3. Function Calls |
|
10 Description: |
|
11 |
|
12 The production CallExpression : MemberExpression Arguments is evaluated as |
|
13 follows: |
|
14 |
|
15 1.Evaluate MemberExpression. |
|
16 2.Evaluate Arguments, producing an internal list of argument values |
|
17 (section 0). |
|
18 3.Call GetValue(Result(1)). |
|
19 4.If Type(Result(3)) is not Object, generate a runtime error. |
|
20 5.If Result(3) does not implement the internal [[Call]] method, generate a |
|
21 runtime error. |
|
22 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, |
|
23 Result(6) is null. |
|
24 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is |
|
25 the same as Result(6). |
|
26 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value |
|
27 and providing the list Result(2) as the argument values. |
|
28 9.Return Result(8). |
|
29 |
|
30 The production CallExpression : CallExpression Arguments is evaluated in |
|
31 exactly the same manner, except that the contained CallExpression is |
|
32 evaluated in step 1. |
|
33 |
|
34 Note: Result(8) will never be of type Reference if Result(3) is a native |
|
35 ECMAScript object. Whether calling a host object can return a value of |
|
36 type Reference is implementation-dependent. |
|
37 |
|
38 Author: christine@netscape.com |
|
39 Date: 12 november 1997 |
|
40 */ |
|
41 |
|
42 var SECTION = "11.2.3-1"; |
|
43 var VERSION = "ECMA_1"; |
|
44 startTest(); |
|
45 var TITLE = "Function Calls"; |
|
46 |
|
47 writeHeaderToLog( SECTION + " "+ TITLE); |
|
48 |
|
49 /* this.eval() is no longer legal syntax. |
|
50 // MemberExpression : this |
|
51 |
|
52 new TestCase( SECTION, |
|
53 "this.eval()", |
|
54 void 0, |
|
55 this.eval() ); |
|
56 |
|
57 new TestCase( SECTION, |
|
58 "this.eval('NaN')", |
|
59 NaN, |
|
60 this.eval("NaN") ); |
|
61 */ |
|
62 // MemberExpression: Identifier |
|
63 |
|
64 var OBJECT = true; |
|
65 |
|
66 new TestCase( SECTION, |
|
67 "OBJECT.toString()", |
|
68 "true", |
|
69 OBJECT.toString() ); |
|
70 |
|
71 // MemberExpression[ Expression] |
|
72 |
|
73 new TestCase( SECTION, |
|
74 "(new Array())['length'].valueOf()", |
|
75 0, |
|
76 (new Array())["length"].valueOf() ); |
|
77 |
|
78 // MemberExpression . Identifier |
|
79 new TestCase( SECTION, |
|
80 "(new Array()).length.valueOf()", |
|
81 0, |
|
82 (new Array()).length.valueOf() ); |
|
83 // new MemberExpression Arguments |
|
84 |
|
85 new TestCase( SECTION, |
|
86 "(new Array(20))['length'].valueOf()", |
|
87 20, |
|
88 (new Array(20))["length"].valueOf() ); |
|
89 |
|
90 test(); |
|
91 |