Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Unified Diff: test/mjsunit/harmony/block-let-declaration-sloppy.js

Issue 1286923002: Add class to existing lexical scoping tests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test bug Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/harmony/block-conflicts-sloppy.js ('k') | test/mjsunit/harmony/block-let-semantics-sloppy.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/block-let-declaration-sloppy.js
diff --git a/test/mjsunit/harmony/block-let-declaration-sloppy.js b/test/mjsunit/harmony/block-let-declaration-sloppy.js
index 9fdc4bd5a7df97e3c7d1e0d1092e04d06f332b20..b94576cabc0c45ec1e1ff1504df6de7fa17fd18a 100644
--- a/test/mjsunit/harmony/block-let-declaration-sloppy.js
+++ b/test/mjsunit/harmony/block-let-declaration-sloppy.js
@@ -33,17 +33,20 @@
let x;
let y = 2;
const z = 4;
+class c { static foo() { return 1; } }
// Block local
{
let y;
let x = 3;
const z = 5;
+ class c { static foo() { return 2; } }
}
assertEquals(undefined, x);
assertEquals(2,y);
assertEquals(4,z);
+assertEquals(1, c.foo());
if (true) {
let y;
@@ -106,6 +109,16 @@ TestLocalDoesNotThrow("for (;false;) var x;");
TestLocalDoesNotThrow("switch (true) { case true: var x; }");
TestLocalDoesNotThrow("switch (true) { default: var x; }");
+// Test class declarations with initialisers in statement positions.
+TestLocalThrows("if (true) class x { };", SyntaxError);
+TestLocalThrows("if (true) {} else class x { };", SyntaxError);
+TestLocalThrows("do class x { }; while (false)", SyntaxError);
+TestLocalThrows("while (false) class x { };", SyntaxError);
+TestLocalThrows("label: class x { };", SyntaxError);
+TestLocalThrows("for (;false;) class x { };", SyntaxError);
+TestLocalDoesNotThrow("switch (true) { case true: class x { }; }");
+TestLocalDoesNotThrow("switch (true) { default: class x { }; }");
+
// Test that redeclarations of functions are only allowed in outermost scope.
TestLocalThrows("{ let f; var f; }");
TestLocalThrows("{ var f; let f; }");
@@ -113,9 +126,13 @@ TestLocalThrows("{ function f() {} let f; }");
TestLocalThrows("{ let f; function f() {} }");
TestLocalThrows("{ function f() {} var f; }");
TestLocalThrows("{ var f; function f() {} }");
+TestLocalThrows("{ function f() {} class f {} }");
+TestLocalThrows("{ class f {}; function f() {} }");
TestLocalThrows("{ function f() {} function f() {} }");
TestLocalThrows("function f() {} let f;");
TestLocalThrows("let f; function f() {}");
+TestLocalThrows("function f() {} class f {}");
+TestLocalThrows("class f {}; function f() {}");
TestLocalDoesNotThrow("function arg() {}");
TestLocalDoesNotThrow("function f() {} var f;");
TestLocalDoesNotThrow("var f; function f() {}");
« no previous file with comments | « test/mjsunit/harmony/block-conflicts-sloppy.js ('k') | test/mjsunit/harmony/block-let-semantics-sloppy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698