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

Side by Side Diff: test/codegen/language/async_switch_test.dart

Issue 1243503007: fixes #221, initial sync*, async, async* implementation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « test/codegen/language/async_star_test.dart ('k') | test/codegen/language/async_test.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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:async";
6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart";
8
9 foo1(a) async {
10 int k = 0;
11 switch(a) {
12 case 1:
13 await 3;
14 k += 1;
15 break;
16 case 2:
17 k += a;
18 return k+2;
19 default: k = 2; /// withDefault: ok
20 }
21 return k;
22 }
23
24 foo2(a) async {
25 int k = 0;
26 switch(await a) {
27 case 1:
28 await 3;
29 k += 1;
30 break;
31 case 2:
32 k += await a;
33 return k+2;
34 default: k = 2; /// withDefault: ok
35 }
36 return k;
37 }
38
39 foo3(a) async {
40 int k = 0;
41 switch(a) {
42 case 1:
43 k += 1;
44 break;
45 case 2:
46 k += a;
47 return k+2;
48 default: k = 2; /// withDefault: ok
49 }
50 return k;
51 }
52
53 foo4(value) async {
54 int k = 0;
55 switch(await value) {
56 case 1:
57 k += 1;
58 break;
59 case 2:
60 k += 2;
61 return 2 + k;
62 default: k = 2; /// withDefault: ok
63 }
64 return k;
65 }
66
67 futureOf(a) async => await a;
68
69 test() async {
70 Expect.equals(1, await foo1(1));
71 Expect.equals(4, await foo1(2));
72 Expect.equals(2, await foo1(3)); /// withDefault: ok
73 Expect.equals(0, await foo1(3)); /// none: ok
74 Expect.equals(1, await foo2(futureOf(1)));
75 Expect.equals(4, await foo2(futureOf(2)));
76 Expect.equals(2, await foo2(futureOf(3))); /// withDefault: ok
77 Expect.equals(0, await foo2(futureOf(3))); /// none: ok
78 Expect.equals(1, await foo3(1));
79 Expect.equals(4, await foo3(2));
80 Expect.equals(2, await foo3(3)); /// withDefault: ok
81 Expect.equals(0, await foo3(3)); /// none: ok
82 Expect.equals(1, await foo4(futureOf(1)));
83 Expect.equals(4, await foo4(futureOf(2)));
84 Expect.equals(2, await foo4(futureOf(3))); /// withDefault: ok
85 Expect.equals(0, await foo4(futureOf(3))); /// none: ok
86 }
87
88 void main() {
89 asyncStart();
90 test().then((_) => asyncEnd());
91 }
OLDNEW
« no previous file with comments | « test/codegen/language/async_star_test.dart ('k') | test/codegen/language/async_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698