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); |
+})(); |