| 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
|
| index e44bf61c537ebb6861dc53ea2b9e8aaef2fa59f1..f27995f89874dd8cfa87aa2925f2a9c1e49084da 100644
|
| --- a/tests/compiler/dart2js/forloop_box_test.dart
|
| +++ b/tests/compiler/dart2js/forloop_box_test.dart
|
| @@ -6,7 +6,7 @@ import "package:expect/expect.dart";
|
| import "package:async_helper/async_helper.dart";
|
| import 'compiler_helper.dart';
|
|
|
| -String TEST = r'''
|
| +String SHOULD_NOT_BE_BOXED_TEST = r'''
|
| main() {
|
| var a;
|
| for (var i=0; i<10; i++) {
|
| @@ -16,7 +16,7 @@ main() {
|
| }
|
| ''';
|
|
|
| -String NEGATIVE_TEST = r'''
|
| +String SHOULD_BE_BOXED_TEST = r'''
|
| run(f) => f();
|
| main() {
|
| var a;
|
| @@ -27,13 +27,31 @@ main() {
|
| }
|
| ''';
|
|
|
| +String ONLY_UPDATE_LOOP_VAR_TEST = r'''
|
| +run(f) => f();
|
| main() {
|
| - asyncTest(() => compileAll(TEST).then((generated) {
|
| + var a;
|
| + for (var i=0; i<10; run(() => i++)) {
|
| + var b = 3;
|
| + a = () => b = i;
|
| + }
|
| + print(a());
|
| +}
|
| +''';
|
| +
|
| +main() {
|
| + asyncTest(() => compileAll(SHOULD_NOT_BE_BOXED_TEST).then((generated) {
|
| Expect.isTrue(generated.contains('main_closure(i)'),
|
| - 'for-loop variable was boxed');
|
| + 'for-loop variable should not have been boxed');
|
| + }));
|
| + asyncTest(() => compileAll(SHOULD_BE_BOXED_TEST).then((generated) {
|
| + Expect.isFalse(generated.contains('main_closure(i)'),
|
| + 'for-loop variable should have been boxed');
|
| }));
|
| - asyncTest(() => compileAll(NEGATIVE_TEST).then((generated) {
|
| + asyncTest(() => compileAll(ONLY_UPDATE_LOOP_VAR_TEST).then((generated) {
|
| Expect.isFalse(generated.contains('main_closure(i)'),
|
| - 'for-loop variable was not boxed');
|
| + 'for-loop variable should have been boxed');
|
| + Expect.isFalse(generated.contains(', _box_0.b = 3,'),
|
| + 'non for-loop captured variable should not be updated in loop');
|
| }));
|
| }
|
|
|