| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 switcher(val) { | 7 switcher(val) { |
| 8 var x = 0; | 8 var x = 0; |
| 9 switch (val) { | 9 switch (val) { |
| 10 case 1: | 10 case 1: |
| 11 x = 100; | 11 x = 100; |
| 12 break; | 12 break; |
| 13 case 2: | 13 case 2: |
| 14 x = 200; | 14 x = 200; |
| 15 break; | 15 break; |
| 16 case 3: | 16 case 3: |
| 17 x = 300; | 17 x = 300; |
| 18 break; | 18 break; |
| 19 default: | 19 default: |
| 20 return 400; | 20 return 400; |
| 21 break; // Intentional dead code (regression test for crash). | 21 break; // Intentional dead code (regression test for crash). |
| 22 } | 22 } |
| 23 return x; | 23 return x; |
| 24 } | 24 } |
| 25 | 25 |
| 26 // Check unambiguated grammar allowing multiple lables per case/default. | 26 // Check unambiguated grammar allowing multiple labels per case/default. |
| 27 switcher2(val) { | 27 switcher2(val) { |
| 28 var x = 0; | 28 var x = 0; |
| 29 switch (val) { | 29 switch (val) { |
| 30 foo: | 30 foo: |
| 31 bar: | 31 bar: |
| 32 case 1: | 32 case 1: |
| 33 baz: | 33 baz: |
| 34 case 2: | 34 case 2: |
| 35 fez: | 35 fez: |
| 36 { | 36 { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Expect.equals(100, switcher2(2)); | 94 Expect.equals(100, switcher2(2)); |
| 95 Expect.equals(200, switcher2(3)); | 95 Expect.equals(200, switcher2(3)); |
| 96 Expect.equals(200, switcher2(4)); | 96 Expect.equals(200, switcher2(4)); |
| 97 Expect.equals(200, switcher2(5)); | 97 Expect.equals(200, switcher2(5)); |
| 98 | 98 |
| 99 switcher3(1); | 99 switcher3(1); |
| 100 Expect.equals(1, x); | 100 Expect.equals(1, x); |
| 101 | 101 |
| 102 badswitches(42); | 102 badswitches(42); |
| 103 } | 103 } |
| OLD | NEW |