test/script/basic/es6/let-load-lib.js

Thu, 04 Sep 2014 18:47:18 +0200

author
hannesw
date
Thu, 04 Sep 2014 18:47:18 +0200
changeset 991
b7a2db4de254
permissions
-rw-r--r--

8051889: Implement block scoping in symbol assignment and scope computation
Reviewed-by: attila, lagergren

hannesw@991 1 /*
hannesw@991 2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
hannesw@991 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@991 4 *
hannesw@991 5 * This code is free software; you can redistribute it and/or modify it
hannesw@991 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@991 7 * published by the Free Software Foundation.
hannesw@991 8 *
hannesw@991 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@991 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@991 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@991 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@991 13 * accompanied this code).
hannesw@991 14 *
hannesw@991 15 * You should have received a copy of the GNU General Public License version
hannesw@991 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@991 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@991 18 *
hannesw@991 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@991 20 * or visit www.oracle.com if you need additional information or have any
hannesw@991 21 * questions.
hannesw@991 22 */
hannesw@991 23
hannesw@991 24 /**
hannesw@991 25 * @subtest
hannesw@991 26 */
hannesw@991 27
hannesw@991 28 "use strict";
hannesw@991 29
hannesw@991 30 // var should be visible in other script, let and const not
hannesw@991 31 var a = 1;
hannesw@991 32 let b = 2;
hannesw@991 33 const c = 3;
hannesw@991 34
hannesw@991 35 // top level function should be visible
hannesw@991 36 function top() {
hannesw@991 37 print("top level function");
hannesw@991 38 }
hannesw@991 39
hannesw@991 40 // block level function not visible outside script
hannesw@991 41 {
hannesw@991 42 function block() {
hannesw@991 43 print("block function");
hannesw@991 44 }
hannesw@991 45
hannesw@991 46 top();
hannesw@991 47 block();
hannesw@991 48 }

mercurial