1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Statements/12.2-1.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 12.2-1.js 1.12 + ECMA Section: The variable statement 1.13 + Description: 1.14 + 1.15 + If the variable statement occurs inside a FunctionDeclaration, the 1.16 + variables are defined with function-local scope in that function, as 1.17 + described in section 10.1.3. Otherwise, they are defined with global 1.18 + scope, that is, they are created as members of the global object, as 1.19 + described in section 0. Variables are created when the execution scope 1.20 + is entered. A Block does not define a new execution scope. Only Program and 1.21 + FunctionDeclaration produce a new scope. Variables are initialized to the 1.22 + undefined value when created. A variable with an Initializer is assigned 1.23 + the value of its AssignmentExpression when the VariableStatement is executed, 1.24 + not when the variable is created. 1.25 + 1.26 + Author: christine@netscape.com 1.27 + Date: 12 november 1997 1.28 +*/ 1.29 + 1.30 +var SECTION = "12.2-1"; 1.31 +var VERSION = "ECMA_1"; 1.32 +startTest(); 1.33 +var TITLE = "The variable statement"; 1.34 + 1.35 +writeHeaderToLog( SECTION +" "+ TITLE); 1.36 + 1.37 +new TestCase( "SECTION", 1.38 + "var x = 3; function f() { var a = x; var x = 23; return a; }; f()", 1.39 + void 0, 1.40 + eval("var x = 3; function f() { var a = x; var x = 23; return a; }; f()") ); 1.41 + 1.42 +test(); 1.43 +