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); |
(...skipping 12 matching lines...) Expand all Loading... |
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 testSideEffects() async { |
| 34 Future foo(int a1, int a2) { |
| 35 Expect.equals(10, a1); |
| 36 Expect.equals(11, a2); |
| 37 return new Future.value(); |
| 38 } |
| 39 int a = 10; |
| 40 await foo(a++, a++); |
| 41 Expect.equals(12, a); |
| 42 } |
| 43 |
33 main() async { | 44 main() async { |
34 testNestedFunctions(); | 45 testNestedFunctions(); |
35 testNamedArguments(); | 46 testNamedArguments(); |
| 47 testSideEffects(); |
36 } | 48 } |
OLD | NEW |