--- a/nashorn/test/script/basic/es6/const-reassign.js Fri Feb 27 18:03:18 2015 +0530
+++ b/nashorn/test/script/basic/es6/const-reassign.js Fri Feb 27 14:33:47 2015 +0100
@@ -31,144 +31,147 @@
"use strict";
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x = 1;\n');
+ const x = 2;
+ x = 1;
+ fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x++;\n');
+ const x = 2;
+ x++;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x--;\n');
+ const x = 2;
+ x--;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
+}
+
+try {
+ const x = 2;
+ ++x;
+ fail("const assignment didn't throw");
+} catch (e) {
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- '++x;\n');
+ const x = 2;
+ --x;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- '--x;\n');
+ const x = 2;
+ x += 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x += 1;\n');
+ const x = 2;
+ x *= 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x *= 1;\n');
+ const x = 2;
+ x /= 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x /= 1;\n');
+ const x = 2;
+ x %= 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x %= 1;\n');
+ const x = 2;
+ x |= 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x |= 1;\n');
+ const x = 2;
+ x &= 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x &= 1;\n');
+ const x = 2;
+ x ^= 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
+}
+
+try {
+ const x = 2;
+ x <<= 1;
+ fail("const assignment didn't throw");
+} catch (e) {
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x ^= 1;\n');
+ const x = 2;
+ x >>= 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x <<= 1;\n');
+ const x = 2;
+ x >>>= 1;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x >>= 1;\n');
+ const x = 2;
+ delete x;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
+const c = 1;
+
try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'x >>>= 1;\n');
+ c = 2;
fail("const assignment didn't throw");
} catch (e) {
- print(e.name);
+ print(e);
}
-try {
- eval('"use strict";\n' +
- 'const x = 2;\n' +
- 'delete x;\n');
- fail("const assignment didn't throw");
-} catch (e) {
- print(e.name);
-}
+(function() {
+ try {
+ c = 2;
+ fail("const assignment didn't throw");
+ } catch (e) {
+ print(e);
+ }
+})();