Thu, 03 Dec 2015 13:41:24 -0800
Merge
hannesw@1105 | 1 | /* |
hannesw@1105 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
hannesw@1105 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
hannesw@1105 | 4 | * |
hannesw@1105 | 5 | * This code is free software; you can redistribute it and/or modify it |
hannesw@1105 | 6 | * under the terms of the GNU General Public License version 2 only, as |
hannesw@1105 | 7 | * published by the Free Software Foundation. |
hannesw@1105 | 8 | * |
hannesw@1105 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
hannesw@1105 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
hannesw@1105 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
hannesw@1105 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
hannesw@1105 | 13 | * accompanied this code). |
hannesw@1105 | 14 | * |
hannesw@1105 | 15 | * You should have received a copy of the GNU General Public License version |
hannesw@1105 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
hannesw@1105 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
hannesw@1105 | 18 | * |
hannesw@1105 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
hannesw@1105 | 20 | * or visit www.oracle.com if you need additional information or have any |
hannesw@1105 | 21 | * questions. |
hannesw@1105 | 22 | */ |
hannesw@1105 | 23 | |
hannesw@1105 | 24 | /** |
hannesw@1105 | 25 | * JDK-8057691: Nashorn: let & const declarations are not shared between scripts |
hannesw@1105 | 26 | * |
hannesw@1105 | 27 | * @test |
hannesw@1105 | 28 | * @run |
hannesw@1105 | 29 | * @option -scripting |
hannesw@1105 | 30 | * @option --language=es6 |
hannesw@1105 | 31 | */ |
hannesw@1105 | 32 | |
hannesw@1105 | 33 | load(__DIR__ + "lexical-toplevel-def.js"); |
hannesw@1105 | 34 | |
hannesw@1105 | 35 | var global = this; |
hannesw@1105 | 36 | |
hannesw@1105 | 37 | function tryIt (code) { |
hannesw@1105 | 38 | try { |
hannesw@1105 | 39 | eval(code) |
hannesw@1105 | 40 | } catch (e) { |
hannesw@1105 | 41 | print(String(e).replace(/\\/g, "/")) |
hannesw@1105 | 42 | } |
hannesw@1105 | 43 | } |
hannesw@1105 | 44 | |
hannesw@1105 | 45 | function loadScript(script) { |
hannesw@1105 | 46 | print(script); |
hannesw@1105 | 47 | try { |
hannesw@1105 | 48 | load(__DIR__ + script); |
hannesw@1105 | 49 | } catch (e) { |
hannesw@1105 | 50 | print(String(e).replace(/\\/g, "/")); |
hannesw@1105 | 51 | } |
hannesw@1105 | 52 | print(VAR); |
hannesw@1105 | 53 | print(LET); |
hannesw@1105 | 54 | print(CONST); |
hannesw@1105 | 55 | print(FUNC); |
hannesw@1105 | 56 | print(GLOBAL); |
hannesw@1105 | 57 | print(global.VAR); |
hannesw@1105 | 58 | print(global.LET); |
hannesw@1105 | 59 | print(global.CONST); |
hannesw@1105 | 60 | print(global.FUNC); |
hannesw@1105 | 61 | print(global.GLOBAL); |
hannesw@1105 | 62 | try { |
hannesw@1105 | 63 | print(SHOULD_NOT_EXIST); |
hannesw@1105 | 64 | } catch (e) { |
hannesw@1105 | 65 | print(String(e).replace(/\\/g, "/")); |
hannesw@1105 | 66 | } |
hannesw@1105 | 67 | print(global.SHOULD_NOT_EXIST); |
hannesw@1105 | 68 | print(Object); |
hannesw@1105 | 69 | print(global.Object); |
hannesw@1105 | 70 | print(); |
hannesw@1105 | 71 | } |
hannesw@1105 | 72 | |
hannesw@1105 | 73 | loadScript("lexical-toplevel-redeclare-var-on-let.js"); |
hannesw@1105 | 74 | loadScript("lexical-toplevel-redeclare-func-on-let.js"); |
hannesw@1105 | 75 | loadScript("lexical-toplevel-redeclare-let-on-var.js"); |
hannesw@1105 | 76 | loadScript("lexical-toplevel-redeclare-let-on-func.js"); |
hannesw@1105 | 77 | loadScript("lexical-toplevel-redeclare-let-on-builtin.js"); |
hannesw@1105 | 78 | loadScript("lexical-toplevel-redeclare-let-on-global.js"); |