Mon, 22 Feb 2016 13:45:00 -0800
Merge
yan@995 | 1 | /* |
yan@995 | 2 | * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. |
yan@995 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
yan@995 | 4 | * |
yan@995 | 5 | * This code is free software; you can redistribute it and/or modify it |
yan@995 | 6 | * under the terms of the GNU General Public License version 2 only, as |
yan@995 | 7 | * published by the Free Software Foundation. |
yan@995 | 8 | * |
yan@995 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
yan@995 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
yan@995 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
yan@995 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
yan@995 | 13 | * accompanied this code). |
yan@995 | 14 | * |
yan@995 | 15 | * You should have received a copy of the GNU General Public License version |
yan@995 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
yan@995 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
yan@995 | 18 | * |
yan@995 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
yan@995 | 20 | * or visit www.oracle.com if you need additional information or have any |
yan@995 | 21 | * questions. |
yan@995 | 22 | */ |
yan@995 | 23 | |
yan@995 | 24 | /** |
yan@995 | 25 | * JDK-8057678: Tests for let&const keywords in Nashorn |
yan@995 | 26 | * |
yan@995 | 27 | * @test |
yan@995 | 28 | * @run |
yan@995 | 29 | * @option --language=es6 |
yan@995 | 30 | * @option -scripting |
yan@995 | 31 | */ |
yan@995 | 32 | |
yan@995 | 33 | |
yan@995 | 34 | function tryIt (code) { |
yan@995 | 35 | try { |
yan@995 | 36 | eval(code) |
yan@995 | 37 | } catch (e) { |
yan@995 | 38 | print(e) |
yan@995 | 39 | } |
yan@995 | 40 | } |
yan@995 | 41 | |
yan@995 | 42 | tryIt(<<CODE |
yan@995 | 43 | let a = 2; |
yan@995 | 44 | do { |
yan@995 | 45 | a--; |
yan@995 | 46 | let b = a; |
yan@995 | 47 | } while (a > 0); |
yan@995 | 48 | print(a) |
yan@995 | 49 | print(b) |
yan@995 | 50 | CODE) |
yan@995 | 51 | |
yan@995 | 52 | tryIt(<<CODE |
yan@995 | 53 | let a = 2 |
yan@995 | 54 | while(a > 0) { |
yan@995 | 55 | a-- |
yan@995 | 56 | let b = a |
yan@995 | 57 | } |
yan@995 | 58 | print(a) |
yan@995 | 59 | print(b) |
yan@995 | 60 | CODE) |
yan@995 | 61 | |
yan@995 | 62 | tryIt(<<CODE |
yan@995 | 63 | let a = 2 |
yan@995 | 64 | while(a > 0) { |
yan@995 | 65 | a-- |
yan@995 | 66 | const b = a |
yan@995 | 67 | } |
yan@995 | 68 | print(a) |
yan@995 | 69 | print(b) |
yan@995 | 70 | CODE) |
yan@995 | 71 | |
yan@995 | 72 | tryIt(<<CODE |
yan@995 | 73 | let a = 2; |
yan@995 | 74 | do { |
yan@995 | 75 | a--; |
yan@995 | 76 | const b = a; |
yan@995 | 77 | } while (a > 0); |
yan@995 | 78 | print(a) |
yan@995 | 79 | print(b) |
yan@995 | 80 | CODE) |