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

Side by Side Diff: tests/language/src/SwitchTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « tests/language/src/SwitchScopeTest.dart ('k') | tests/language/src/SyntaxTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // Test switch statement.
5
6 class Switcher {
7
8 Switcher() { }
9
10 test1 (val) {
11 var x = 0;
12 switch (val) {
13 case 1:
14 x = 100; break;
15 case 2:
16 case 3:
17 x = 200; break;
18 case "mister string":
19 return 300;
20 case 4:
21 default: {
22 x = 400; break;
23 }
24 }
25 return x;
26 }
27
28 test2 (val) {
29 switch (val) {
30 case true: return 100;
31 case 1: return 200;
32 case "1": return 300;
33 default: return 400;
34 }
35 }
36
37 test3(val) {
38 final int temp = 5;
39 switch (true) {
40 case temp == val:
41 return true;
42 }
43 return false;
44 }
45 }
46
47
48 class SwitchTest {
49 static testMain() {
50 Switcher s = new Switcher();
51 Expect.equals(100, s.test1(1));
52 Expect.equals(200, s.test1(2));
53 Expect.equals(200, s.test1(3));
54 Expect.equals(300, s.test1("mister string"));
55 Expect.equals(400, s.test1(4));
56 Expect.equals(400, s.test1(5));
57
58 Expect.equals(200, s.test2(1));
59 Expect.equals(300, s.test2("1"));
60
61 Expect.equals(true, s.test3(5));
62 Expect.equals(false, s.test3(6));
63 }
64 }
65
66 main() {
67 SwitchTest.testMain();
68 }
OLDNEW
« no previous file with comments | « tests/language/src/SwitchScopeTest.dart ('k') | tests/language/src/SyntaxTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698