| OLD | NEW |
| 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; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 { |
| 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 |
| 53 futureOf(a) async => await a; | 67 futureOf(a) async => await a; |
| 54 | 68 |
| 55 test() async { | 69 test() async { |
| 56 Expect.equals(1, await foo1(1)); | 70 Expect.equals(1, await foo1(1)); |
| 57 Expect.equals(4, await foo1(2)); | 71 Expect.equals(4, await foo1(2)); |
| 58 Expect.equals(2, await foo1(3)); /// withDefault: ok | 72 Expect.equals(2, await foo1(3)); /// withDefault: ok |
| 59 Expect.equals(0, await foo1(3)); /// none: ok | 73 Expect.equals(0, await foo1(3)); /// none: ok |
| 60 Expect.equals(1, await foo2(futureOf(1))); | 74 Expect.equals(1, await foo2(futureOf(1))); |
| 61 Expect.equals(4, await foo2(futureOf(2))); | 75 Expect.equals(4, await foo2(futureOf(2))); |
| 62 Expect.equals(2, await foo2(futureOf(3))); /// withDefault: ok | 76 Expect.equals(2, await foo2(futureOf(3))); /// withDefault: ok |
| 63 Expect.equals(0, await foo2(futureOf(3))); /// none: ok | 77 Expect.equals(0, await foo2(futureOf(3))); /// none: ok |
| 64 Expect.equals(1, await foo3(1)); | 78 Expect.equals(1, await foo3(1)); |
| 65 Expect.equals(4, await foo3(2)); | 79 Expect.equals(4, await foo3(2)); |
| 66 Expect.equals(2, await foo3(3)); /// withDefault: ok | 80 Expect.equals(2, await foo3(3)); /// withDefault: ok |
| 67 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))); |
| 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 |
| 68 } | 86 } |
| 69 | 87 |
| 70 void main() { | 88 void main() { |
| 71 asyncStart(); | 89 asyncStart(); |
| 72 test().then((_) => asyncEnd()); | 90 test().then((_) => asyncEnd()); |
| 73 } | 91 } |
| OLD | NEW |