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

Side by Side Diff: tests/language_strong/async_switch_test.dart

Issue 2765693002: Update all tests (Closed)
Patch Set: Created 3 years, 9 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 "dart:async"; 5 import "dart:async";
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 8
9 foo1(a) async { 9 foo1(a) async {
10 int k = 0; 10 int k = 0;
11 switch(a) { 11 switch(a) {
12 case 1: 12 case 1:
13 await 3; 13 await 3;
14 k += 1; 14 k += 1;
15 break; 15 break;
16 case 2: 16 case 2:
17 k += a; 17 k += a;
18 return k+2; 18 return k+2;
19 default: k = 2; /// withDefault: ok 19 default: k = 2; //# withDefault: ok
20 } 20 }
21 return k; 21 return k;
22 } 22 }
23 23
24 foo2(a) async { 24 foo2(a) async {
25 int k = 0; 25 int k = 0;
26 switch(await a) { 26 switch(await a) {
27 case 1: 27 case 1:
28 await 3; 28 await 3;
29 k += 1; 29 k += 1;
30 break; 30 break;
31 case 2: 31 case 2:
32 k += await a; 32 k += await a;
33 return k+2; 33 return k+2;
34 default: k = 2; /// withDefault: ok 34 default: k = 2; //# withDefault: ok
35 } 35 }
36 return k; 36 return k;
37 } 37 }
38 38
39 foo3(a) async { 39 foo3(a) async {
40 int k = 0; 40 int k = 0;
41 switch(a) { 41 switch(a) {
42 case 1: 42 case 1:
43 k += 1; 43 k += 1;
44 break; 44 break;
45 case 2: 45 case 2:
46 k += a; 46 k += a;
47 return k+2; 47 return k+2;
48 default: k = 2; /// withDefault: ok 48 default: k = 2; //# withDefault: ok
49 } 49 }
50 return k; 50 return k;
51 } 51 }
52 52
53 foo4(value) async { 53 foo4(value) async {
54 int k = 0; 54 int k = 0;
55 switch(await value) { 55 switch(await value) {
56 case 1: 56 case 1:
57 k += 1; 57 k += 1;
58 break; 58 break;
59 case 2: 59 case 2:
60 k += 2; 60 k += 2;
61 return 2 + k; 61 return 2 + k;
62 default: k = 2; /// withDefault: ok 62 default: k = 2; //# withDefault: ok
63 } 63 }
64 return k; 64 return k;
65 } 65 }
66 66
67 futureOf(a) async => await a; 67 futureOf(a) async => await a;
68 68
69 test() async { 69 test() async {
70 Expect.equals(1, await foo1(1)); 70 Expect.equals(1, await foo1(1));
71 Expect.equals(4, await foo1(2)); 71 Expect.equals(4, await foo1(2));
72 Expect.equals(2, await foo1(3)); /// withDefault: ok 72 Expect.equals(2, await foo1(3)); //# withDefault: ok
73 Expect.equals(0, await foo1(3)); /// none: ok 73 Expect.equals(0, await foo1(3)); //# none: ok
74 Expect.equals(1, await foo2(futureOf(1))); 74 Expect.equals(1, await foo2(futureOf(1)));
75 Expect.equals(4, await foo2(futureOf(2))); 75 Expect.equals(4, await foo2(futureOf(2)));
76 Expect.equals(2, await foo2(futureOf(3))); /// withDefault: ok 76 Expect.equals(2, await foo2(futureOf(3))); //# withDefault: ok
77 Expect.equals(0, await foo2(futureOf(3))); /// none: ok 77 Expect.equals(0, await foo2(futureOf(3))); //# none: ok
78 Expect.equals(1, await foo3(1)); 78 Expect.equals(1, await foo3(1));
79 Expect.equals(4, await foo3(2)); 79 Expect.equals(4, await foo3(2));
80 Expect.equals(2, await foo3(3)); /// withDefault: ok 80 Expect.equals(2, await foo3(3)); //# withDefault: ok
81 Expect.equals(0, await foo3(3)); /// none: ok 81 Expect.equals(0, await foo3(3)); //# none: ok
82 Expect.equals(1, await foo4(futureOf(1))); 82 Expect.equals(1, await foo4(futureOf(1)));
83 Expect.equals(4, await foo4(futureOf(2))); 83 Expect.equals(4, await foo4(futureOf(2)));
84 Expect.equals(2, await foo4(futureOf(3))); /// withDefault: ok 84 Expect.equals(2, await foo4(futureOf(3))); //# withDefault: ok
85 Expect.equals(0, await foo4(futureOf(3))); /// none: ok 85 Expect.equals(0, await foo4(futureOf(3))); //# none: ok
86 } 86 }
87 87
88 void main() { 88 void main() {
89 asyncStart(); 89 asyncStart();
90 test().then((_) => asyncEnd()); 90 test().then((_) => asyncEnd());
91 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698