Debian Codegraph @

rhino/testsrc/tests/ecma/extensions/10.1.4-9.js

raw symbols SCIP
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 gTestfile = '10.1.4-9.js';
7
8 /**
9 File Name: 10.1.4-9.js
10 ECMA Section: 10.1.4 Scope Chain and Identifier Resolution
11 Description:
12 Every execution context has associated with it a scope chain. This is
13 logically a list of objects that are searched when binding an Identifier.
14 When control enters an execution context, the scope chain is created and
15 is populated with an initial set of objects, depending on the type of
16 code. When control leaves the execution context, the scope chain is
17 destroyed.
18
19 During execution, the scope chain of the execution context is affected
20 only by WithStatement. When execution enters a with block, the object
21 specified in the with statement is added to the front of the scope chain.
22 When execution leaves a with block, whether normally or via a break or
23 continue statement, the object is removed from the scope chain. The object
24 being removed will always be the first object in the scope chain.
25
26 During execution, the syntactic production PrimaryExpression : Identifier
27 is evaluated using the following algorithm:
28
29 1. Get the next object in the scope chain. If there isn't one, go to step 5.
30 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as
31 the property.
32 3. If Result(2) is true, return a value of type Reference whose base object
33 is Result(l) and whose property name is the Identifier.
34 4. Go to step 1.
35 5. Return a value of type Reference whose base object is null and whose
36 property name is the Identifier.
37 The result of binding an identifier is always a value of type Reference with
38 its member name component equal to the identifier string.
39 Author: [email protected]
40 Date: 12 november 1997
41 */
42 var SECTION = "10.1.4-9";
43 var VERSION = "ECMA_2";
44 startTest();
45
46 writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution");
47
48 new TestCase( SECTION, "NEW_PROPERTY = " );
49
50 test();
51
52 function test() {
53 for ( gTc=0; gTc < gTestcases.length; gTc++ ) {
54
55 var MYOBJECT = new MyObject();
56 var RESULT = "hello";
57
58 with ( MYOBJECT ) {
59 NEW_PROPERTY = RESULT;
60 }
61 gTestcases[gTc].actual = NEW_PROPERTY;
62 gTestcases[gTc].expect = RESULT;
63
64 gTestcases[gTc].passed = writeTestCaseResult(
65 gTestcases[gTc].expect,
66 gTestcases[gTc].actual,
67 gTestcases[gTc].description +" = "+
68 gTestcases[gTc].actual );
69
70 gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value ";
71 }
72 stopTest();
73 return ( gTestcases );
74 }
75 function MyObject( n ) {
76 this.__proto__ = Number.prototype;
77 }