| Index: test/mjsunit/const-redecl.js
|
| diff --git a/test/mjsunit/const-redecl.js b/test/mjsunit/const-redecl.js
|
| index 26d765b97a312c77f5d6a56dac545383bd20a4eb..b57878fd7715c9749eb338faa0fbfd09b1a92ef0 100644
|
| --- a/test/mjsunit/const-redecl.js
|
| +++ b/test/mjsunit/const-redecl.js
|
| @@ -98,7 +98,8 @@ function TestAll(expected,s,opt_e) {
|
| var msg = s;
|
| if (opt_e) { e = opt_e; msg += "; " + opt_e; }
|
| assertEquals(expected, TestLocal(s,e), "local:'" + msg + "'");
|
| - assertEquals(expected, TestGlobal(s,e), "global:'" + msg + "'");
|
| + // Redeclarations of global consts do not throw, they are silently ignored.
|
| + assertEquals(42, TestGlobal(s, 42), "global:'" + msg + "'");
|
| assertEquals(expected, TestContext(s,e), "context:'" + msg + "'");
|
| }
|
|
|
| @@ -218,3 +219,41 @@ TestAll(0, "var a,b,c,d,e,f,g,h; " + loop, "x");
|
| // Test that const inside with behaves correctly.
|
| TestAll(87, "with ({x:42}) { const x = 87; }", "x");
|
| TestAll(undefined, "with ({x:42}) { const x; }", "x");
|
| +
|
| +
|
| +// Additional tests for how various combinations of re-declarations affect
|
| +// the values of the var/const in question.
|
| +try {
|
| + eval("var undefined;");
|
| +} catch (ex) {
|
| + assertUnreachable("undefined (1) has thrown");
|
| +}
|
| +
|
| +var original_undef = undefined;
|
| +var undefined = 1; // Should be silently ignored.
|
| +assertEquals(original_undef, undefined, "undefined got overwritten");
|
| +undefined = original_undef;
|
| +
|
| +var a; const a; const a = 1;
|
| +// According to ES5 10.5.8.c, the assignment "= 1" should be ignored.
|
| +assertEquals(a, undefined, "a has wrong value");
|
| +a = 2;
|
| +assertEquals(a, 2, "a should be writable");
|
| +
|
| +var b = 1; const b = 2;
|
| +assertEquals(b, 1, "b has wrong value");
|
| +
|
| +var c = 1; const c = 2; const c = 3;
|
| +assertEquals(c, 1, "c has wrong value");
|
| +
|
| +const d = 1; const d = 2;
|
| +assertEquals(d, 1, "d has wrong value");
|
| +
|
| +const e = 1; var e = 2;
|
| +assertEquals(e, 1, "e has wrong value");
|
| +
|
| +const f = 1; const f;
|
| +assertEquals(f, 1, "f has wrong value");
|
| +
|
| +var g; const g = 1;
|
| +assertEquals(g, undefined, "g has wrong value");
|
|
|