| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 import "package:async_helper/async_helper.dart"; |
| 7 import 'compiler_helper.dart'; |
| 8 |
| 9 String TEST = r''' |
| 10 main() { |
| 11 var a; |
| 12 for (var i=0; i<10; i++) { |
| 13 a = () => i; |
| 14 } |
| 15 print(a()); |
| 16 } |
| 17 '''; |
| 18 |
| 19 String NEGATIVE_TEST = r''' |
| 20 run(f) => f(); |
| 21 main() { |
| 22 var a; |
| 23 for (var i=0; i<10; run(() => i++)) { |
| 24 a = () => i; |
| 25 } |
| 26 print(a()); |
| 27 } |
| 28 '''; |
| 29 |
| 30 main() { |
| 31 asyncTest(() => compileAll(TEST).then((generated) { |
| 32 Expect.isTrue(generated.contains('main_closure(i)'), |
| 33 'for-loop variable was boxed'); |
| 34 })); |
| 35 asyncTest(() => compileAll(NEGATIVE_TEST).then((generated) { |
| 36 Expect.isFalse(generated.contains('main_closure(i)'), |
| 37 'for-loop variable was not boxed'); |
| 38 })); |
| 39 } |
| OLD | NEW |