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

Unified Diff: test/mjsunit/switch.js

Issue 1309163003: Add a separate scope for switch (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Avoid arrow function in test 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/regress/regress-4377.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/switch.js
diff --git a/test/mjsunit/switch.js b/test/mjsunit/switch.js
index 6a61fe5940933ddb68ef4aeaf482b1fd92ec7aa4..4722e9e5d8063859d097b09a1b9d3a9d2427d9bf 100644
--- a/test/mjsunit/switch.js
+++ b/test/mjsunit/switch.js
@@ -460,3 +460,58 @@ function test_switches(opt) {
test_switches(false);
test_switches(true);
+
+
+// Test labeled and anonymous breaks in switch statements
+(function test_switch_break() {
+ A: for (var i = 1; i < 10; i++) {
+ switch (i) {
+ case 1:
+ break A;
+ }
+ }
+ assertEquals(1, i);
+
+ for (var i = 1; i < 10; i++) {
+ B: switch (i) {
+ case 1:
+ break B;
+ }
+ }
+ assertEquals(10, i);
+
+ for (var i = 1; i < 10; i++) {
+ switch (i) {
+ case 1:
+ break;
+ }
+ }
+ assertEquals(10, i);
+
+ switch (1) {
+ case 1:
+ C: for (var i = 1; i < 10; i++) {
+ break C;
+ }
+ i = 2;
+ }
+ assertEquals(2, i);
+
+ switch (1) {
+ case 1:
+ for (var i = 1; i < 10; i++) {
+ break;
+ }
+ i = 2;
+ }
+ assertEquals(2, i);
+
+ D: switch (1) {
+ case 1:
+ for (var i = 1; i < 10; i++) {
+ break D;
+ }
+ i = 2;
+ }
+ assertEquals(1, i);
+})();
« no previous file with comments | « test/mjsunit/regress/regress-4377.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698