]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js
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/
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.
11 * The Original Code is Mozilla Communicator client code, released March
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
23 File Name: 10.2.2-1.js
24 ECMA Section: 10.2.2 Eval Code
27 When control enters an execution context for eval code, the previous
28 active execution context, referred to as the calling context, is used to
29 determine the scope chain, the variable object, and the this value. If
30 there is no calling context, then initializing the scope chain, variable
31 instantiation, and determination of the this value are performed just as
34 The scope chain is initialized to contain the same objects, in the same
35 order, as the calling context's scope chain. This includes objects added
36 to the calling context's scope chain by WithStatement.
38 Variable instantiation is performed using the calling context's variable
39 object and using empty property attributes.
41 The this value is the same as the this value of the calling context.
43 Author: christine@netscape.com
44 Date: 12 november 1997
47 var SECTION
= "10.2.2-1";
48 var VERSION
= "ECMA_1";
50 var TITLE
= "Eval Code";
52 writeHeaderToLog( SECTION
+ " "+ TITLE
);
54 var testcases
= new Array();
56 var THIS
= eval("this");
58 testcases
[tc
++] = new TestCase( SECTION
,
63 var GLOBAL_PROPERTIES
= new Array();
67 GLOBAL_PROPERTIES
[i
++] = p
;
70 for ( i
= 0; i
< GLOBAL_PROPERTIES
.length
; i
++ ) {
71 testcases
[tc
++] = new TestCase( SECTION
,
72 GLOBAL_PROPERTIES
[i
] +" == THIS["+GLOBAL_PROPERTIES
[i
]+"]",
74 eval(GLOBAL_PROPERTIES
[i
]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") );
77 // this in eval statements is the same as this value of the calling context
79 var RESULT
= THIS
== this;
81 testcases
[tc
++] = new TestCase( SECTION
,
82 "eval( 'this == THIS' )",
86 var RESULT
= THIS
+'';
88 testcases
[tc
++] = new TestCase( SECTION
,
89 "eval( 'this + \"\"' )",
94 testcases
[tc
++] = new TestCase( SECTION
,
95 "eval( 'this == THIS' )",
97 eval( "this == THIS" ) );
99 testcases
[tc
++] = new TestCase( SECTION
,
100 "eval( 'this + \"\"' )",
108 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
109 testcases
[tc
].passed
= writeTestCaseResult(
110 testcases
[tc
].expect
,
111 testcases
[tc
].actual
,
112 testcases
[tc
].description
+" = "+
113 testcases
[tc
].actual
);
115 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
118 return ( testcases
);