1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code, released
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 gTestfile = '10.1.4-10.js';
42 File Name: 10.1.4-10.js
43 ECMA Section: 10.1.4 Scope Chain and Identifier Resolution
45 Every execution context has associated with it a scope chain. This is
46 logically a list of objects that are searched when binding an Identifier.
47 When control enters an execution context, the scope chain is created and
48 is populated with an initial set of objects, depending on the type of
49 code. When control leaves the execution context, the scope chain is
52 During execution, the scope chain of the execution context is affected
53 only by WithStatement. When execution enters a with block, the object
54 specified in the with statement is added to the front of the scope chain.
55 When execution leaves a with block, whether normally or via a break or
56 continue statement, the object is removed from the scope chain. The object
57 being removed will always be the first object in the scope chain.
59 During execution, the syntactic production PrimaryExpression : Identifier
60 is evaluated using the following algorithm:
62 1. Get the next object in the scope chain. If there isn't one, go to step 5.
63 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as
65 3. If Result(2) is true, return a value of type Reference whose base object
66 is Result(l) and whose property name is the Identifier.
68 5. Return a value of type Reference whose base object is null and whose
69 property name is the Identifier.
70 The result of binding an identifier is always a value of type Reference with
71 its member name component equal to the identifier string.
72 Author: christine@netscape.com
73 Date: 12 november 1997
75 var SECTION = "10.1.4-10";
76 var VERSION = "ECMA_1";
79 writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution");
81 new TestCase( "SECTION", "MYOBJECT.toString()" );
86 for ( gTc=0; gTc < gTestcases.length; gTc++ ) {
88 var MYOBJECT = new Number( VALUE );
91 gTestcases[gTc].actual = toString();
92 gTestcases[gTc].expect = String(VALUE);
95 gTestcases[gTc].passed = writeTestCaseResult(
96 gTestcases[gTc].expect,
97 gTestcases[gTc].actual,
98 gTestcases[gTc].description +" = "+
99 gTestcases[gTc].actual );
101 gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value ";
104 return ( gTestcases );