OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // VMOptions=--enable_async | 5 // VMOptions=--enable_async |
6 // | 6 // |
7 // Regression test for issue 21536. | 7 |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 | 11 |
12 later(vodka) => new Future.value(vodka); | 12 later(vodka) => new Future.value(vodka); |
13 | 13 |
14 manana(tequila) async => tequila; | 14 manana(tequila) async => tequila; |
15 | 15 |
16 main() async { | 16 // Regression test for issue 21536. |
| 17 testNestedFunctions() async { |
17 var a = await later('Asterix').then((tonic) { | 18 var a = await later('Asterix').then((tonic) { |
18 return later(tonic); | 19 return later(tonic); |
19 }); | 20 }); |
20 var o = await manana('Obelix').then(manana); | 21 var o = await manana('Obelix').then(manana); |
21 Expect.equals("$a and $o", "Asterix and Obelix"); | 22 Expect.equals("$a and $o", "Asterix and Obelix"); |
22 } | 23 } |
| 24 |
| 25 addLater({a, b}) => new Future.value(a + b); |
| 26 |
| 27 // Regression test for issue 21480. |
| 28 testNamedArguments() async { |
| 29 var sum = await addLater(a:5, b:10); |
| 30 Expect.equals(sum, 15); |
| 31 sum = await addLater(b:11, a:-11); |
| 32 Expect.equals(sum, 0); |
| 33 } |
| 34 |
| 35 main() async { |
| 36 testNestedFunctions(); |
| 37 testNamedArguments(); |
| 38 } |
OLD | NEW |