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