Tue, 03 Nov 2015 07:19:18 -0800
Added tag jdk8u66-b33 for changeset 3629a9cd6627
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 | * JDK-8051889: Implement block scoping in symbol assignment and scope computation |
hannesw@991 | 26 | * |
hannesw@991 | 27 | * @test |
hannesw@991 | 28 | * @run |
hannesw@991 | 29 | * @option --language=es6 */ |
hannesw@991 | 30 | |
hannesw@991 | 31 | "use strict"; |
hannesw@991 | 32 | |
hannesw@991 | 33 | try { |
hannesw@1243 | 34 | const x = 2; |
hannesw@1243 | 35 | x = 1; |
hannesw@1243 | 36 | fail("const assignment didn't throw"); |
hannesw@991 | 37 | } catch (e) { |
hannesw@1243 | 38 | print(e); |
hannesw@991 | 39 | } |
hannesw@991 | 40 | |
hannesw@991 | 41 | try { |
hannesw@1243 | 42 | const x = 2; |
hannesw@1243 | 43 | x++; |
hannesw@991 | 44 | fail("const assignment didn't throw"); |
hannesw@991 | 45 | } catch (e) { |
hannesw@1243 | 46 | print(e); |
hannesw@991 | 47 | } |
hannesw@991 | 48 | |
hannesw@991 | 49 | try { |
hannesw@1243 | 50 | const x = 2; |
hannesw@1243 | 51 | x--; |
hannesw@991 | 52 | fail("const assignment didn't throw"); |
hannesw@991 | 53 | } catch (e) { |
hannesw@1243 | 54 | print(e); |
hannesw@991 | 55 | } |
hannesw@991 | 56 | |
hannesw@991 | 57 | try { |
hannesw@1243 | 58 | const x = 2; |
hannesw@1243 | 59 | ++x; |
hannesw@991 | 60 | fail("const assignment didn't throw"); |
hannesw@991 | 61 | } catch (e) { |
hannesw@1243 | 62 | print(e); |
hannesw@991 | 63 | } |
hannesw@991 | 64 | |
hannesw@991 | 65 | try { |
hannesw@1243 | 66 | const x = 2; |
hannesw@1243 | 67 | --x; |
hannesw@991 | 68 | fail("const assignment didn't throw"); |
hannesw@991 | 69 | } catch (e) { |
hannesw@1243 | 70 | print(e); |
hannesw@991 | 71 | } |
hannesw@991 | 72 | |
hannesw@991 | 73 | try { |
hannesw@1243 | 74 | const x = 2; |
hannesw@1243 | 75 | x += 1; |
hannesw@991 | 76 | fail("const assignment didn't throw"); |
hannesw@991 | 77 | } catch (e) { |
hannesw@1243 | 78 | print(e); |
hannesw@991 | 79 | } |
hannesw@991 | 80 | |
hannesw@991 | 81 | try { |
hannesw@1243 | 82 | const x = 2; |
hannesw@1243 | 83 | x *= 1; |
hannesw@991 | 84 | fail("const assignment didn't throw"); |
hannesw@991 | 85 | } catch (e) { |
hannesw@1243 | 86 | print(e); |
hannesw@991 | 87 | } |
hannesw@991 | 88 | |
hannesw@991 | 89 | try { |
hannesw@1243 | 90 | const x = 2; |
hannesw@1243 | 91 | x /= 1; |
hannesw@991 | 92 | fail("const assignment didn't throw"); |
hannesw@991 | 93 | } catch (e) { |
hannesw@1243 | 94 | print(e); |
hannesw@991 | 95 | } |
hannesw@991 | 96 | |
hannesw@991 | 97 | try { |
hannesw@1243 | 98 | const x = 2; |
hannesw@1243 | 99 | x %= 1; |
hannesw@991 | 100 | fail("const assignment didn't throw"); |
hannesw@991 | 101 | } catch (e) { |
hannesw@1243 | 102 | print(e); |
hannesw@991 | 103 | } |
hannesw@991 | 104 | |
hannesw@991 | 105 | try { |
hannesw@1243 | 106 | const x = 2; |
hannesw@1243 | 107 | x |= 1; |
hannesw@991 | 108 | fail("const assignment didn't throw"); |
hannesw@991 | 109 | } catch (e) { |
hannesw@1243 | 110 | print(e); |
hannesw@991 | 111 | } |
hannesw@991 | 112 | |
hannesw@991 | 113 | try { |
hannesw@1243 | 114 | const x = 2; |
hannesw@1243 | 115 | x &= 1; |
hannesw@991 | 116 | fail("const assignment didn't throw"); |
hannesw@991 | 117 | } catch (e) { |
hannesw@1243 | 118 | print(e); |
hannesw@991 | 119 | } |
hannesw@991 | 120 | |
hannesw@991 | 121 | try { |
hannesw@1243 | 122 | const x = 2; |
hannesw@1243 | 123 | x ^= 1; |
hannesw@991 | 124 | fail("const assignment didn't throw"); |
hannesw@991 | 125 | } catch (e) { |
hannesw@1243 | 126 | print(e); |
hannesw@991 | 127 | } |
hannesw@991 | 128 | |
hannesw@991 | 129 | try { |
hannesw@1243 | 130 | const x = 2; |
hannesw@1243 | 131 | x <<= 1; |
hannesw@991 | 132 | fail("const assignment didn't throw"); |
hannesw@991 | 133 | } catch (e) { |
hannesw@1243 | 134 | print(e); |
hannesw@991 | 135 | } |
hannesw@991 | 136 | |
hannesw@991 | 137 | try { |
hannesw@1243 | 138 | const x = 2; |
hannesw@1243 | 139 | x >>= 1; |
hannesw@991 | 140 | fail("const assignment didn't throw"); |
hannesw@991 | 141 | } catch (e) { |
hannesw@1243 | 142 | print(e); |
hannesw@991 | 143 | } |
hannesw@991 | 144 | |
hannesw@991 | 145 | try { |
hannesw@1243 | 146 | const x = 2; |
hannesw@1243 | 147 | x >>>= 1; |
hannesw@991 | 148 | fail("const assignment didn't throw"); |
hannesw@991 | 149 | } catch (e) { |
hannesw@1243 | 150 | print(e); |
hannesw@991 | 151 | } |
hannesw@991 | 152 | |
hannesw@991 | 153 | try { |
hannesw@1243 | 154 | const x = 2; |
hannesw@1243 | 155 | delete x; |
hannesw@991 | 156 | fail("const assignment didn't throw"); |
hannesw@991 | 157 | } catch (e) { |
hannesw@1243 | 158 | print(e); |
hannesw@991 | 159 | } |
hannesw@1243 | 160 | |
hannesw@1243 | 161 | const c = 1; |
hannesw@1243 | 162 | |
hannesw@1243 | 163 | try { |
hannesw@1243 | 164 | c = 2; |
hannesw@1243 | 165 | fail("const assignment didn't throw"); |
hannesw@1243 | 166 | } catch (e) { |
hannesw@1243 | 167 | print(e); |
hannesw@1243 | 168 | } |
hannesw@1243 | 169 | |
hannesw@1243 | 170 | (function() { |
hannesw@1243 | 171 | try { |
hannesw@1243 | 172 | c = 2; |
hannesw@1243 | 173 | fail("const assignment didn't throw"); |
hannesw@1243 | 174 | } catch (e) { |
hannesw@1243 | 175 | print(e); |
hannesw@1243 | 176 | } |
hannesw@1243 | 177 | })(); |