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

Side by Side Diff: tests/language/switch_fallthru_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Check that FallThroughError is thrown if switch clause does not terminate. 4 // Check that FallThroughError is thrown if switch clause does not terminate.
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 class SwitchFallthruTest { 8 class SwitchFallthruTest {
9 static String test(int n) { 9 static String test(int n) {
10 String result = "foo"; 10 String result = "foo";
11 switch (n) { 11 switch (n) {
12 case 0: 12 case 0:
13 result = "zero"; 13 result = "zero";
14 break; 14 break;
15 case 1: 15 case 1:
16 result = "one"; 16 result = "one";
17 // fall-through, throw implicit FallThroughError here. 17 // fall-through, throw implicit FallThroughError here.
18 case 9: 18 case 9:
19 result = "nine"; 19 result = "nine";
20 // No implicit FallThroughError at end of switch statement. 20 // No implicit FallThroughError at end of switch statement.
21 } 21 }
22 return result; 22 return result;
23 } 23 }
24 24
25 static testMain() { 25 static testMain() {
26 Expect.equals("zero", test(0)); 26 Expect.equals("zero", test(0));
27 bool fallthroughCaught = false; 27 bool fallthroughCaught = false;
28 try { 28 try {
29 test(1); 29 test(1);
30 } on FallThroughError catch (e) { 30 } on FallThroughError catch (e) {
31 fallthroughCaught = true; 31 fallthroughCaught = true;
32 } 32 }
33 Expect.equals(true, fallthroughCaught); 33 Expect.equals(true, fallthroughCaught);
34 Expect.equals("nine", test(9)); 34 Expect.equals("nine", test(9));
35 Expect.equals("foo", test(99)); 35 Expect.equals("foo", test(99));
36 } 36 }
37 } 37 }
38 38
39 main() { 39 main() {
40 SwitchFallthruTest.testMain(); 40 SwitchFallthruTest.testMain();
41 } 41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698