Chromium Code Reviews| Index: tests/compiler/dart2js/forloop_box_test.dart |
| diff --git a/tests/compiler/dart2js/forloop_box_test.dart b/tests/compiler/dart2js/forloop_box_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7b3273e38047e4f6f7a6ad0497820e0c166a1306 |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/forloop_box_test.dart |
| @@ -0,0 +1,37 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import "package:expect/expect.dart"; |
| +import "package:async_helper/async_helper.dart"; |
| +import 'compiler_helper.dart'; |
| + |
| +String TEST = r''' |
| +main() { |
| + var a; |
| + for (var i=0; i<10; i++) { |
| + a = () => i; |
| + } |
| + print(a()); |
| +} |
| +'''; |
| + |
| +String NEGATIVE_TEST = r''' |
| +run(f) => f(); |
| +main() { |
| + var a; |
| + for (var i=0; i<10; run(() => i++)) { |
| + a = () => i; |
| + } |
| + print(a()); |
| +} |
| +'''; |
| + |
| +main() { |
| + asyncTest(() => compileAll(TEST).then((generated) { |
| + Expect.isTrue(generated.contains('main_closure(i)'), 'for-loop variable was boxed'); |
|
karlklose
2015/01/13 13:22:47
Break these strings to the next line.
|
| + })); |
| + asyncTest(() => compileAll(NEGATIVE_TEST).then((generated) { |
| + Expect.isFalse(generated.contains('main_closure(i)'), 'for-loop variable was not boxed'); |
| + })); |
| +} |