OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // VMOptions=--enable_async --optimization-counter-threshold=10 |
| 6 |
| 7 // This tests that captured parameters (by the async-closure) are |
| 8 // correctly treated in try-catch generated in the async function. |
| 9 // They must be skipped when generating sync-code in the optimized |
| 10 // try-block. |
| 11 |
| 12 import 'package:expect/expect.dart'; |
| 13 |
| 14 import 'dart:async'; |
| 15 |
| 16 check(value) { |
| 17 try { |
| 18 } finally { |
| 19 return value; |
| 20 } |
| 21 } |
| 22 |
| 23 fail() { |
| 24 try { |
| 25 Expect.isTrue(false); |
| 26 } finally { } |
| 27 } |
| 28 |
| 29 foo(i) async { |
| 30 var k = await 77; |
| 31 var a = "abc${k}"; |
| 32 if (a != "abc77") fail(); |
| 33 return k; |
| 34 } |
| 35 |
| 36 |
| 37 main() { |
| 38 for (int i = 0; i < 20; i++) { |
| 39 foo(i).then((value) => Expect.equals(77, value)); |
| 40 } |
| 41 } |
OLD | NEW |