~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/ecma/ExecutionContexts/10.1.4-6.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

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