Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Unified Diff: tests/compiler/dart2js/forloop_box_test.dart

Issue 2964783002: Reapply "Added for-loop variable tracking and regular closures/initializers captured variable track… (Closed)
Patch Set: . Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/dart2js.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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');
}));
}
« no previous file with comments | « tests/compiler/dart2js/dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698