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

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

Issue 2961253005: Added for-loop variable tracking and regular closures/initializers captured variable tracking. (Closed)
Patch Set: . Created 3 years, 6 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
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..afa9df7c95047ad9f84f55edcd7dd2acfbec0b93 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() {
+ var a;
+ for (var i=0; i<10; run(() => i++)) {
+ var b = 3;
+ a = () => b = i;
+ }
+ print(a());
+}
+''';
+
main() {
- asyncTest(() => compileAll(TEST).then((generated) {
+ asyncTest(() => compileAll(SHOULD_NOT_BE_BOXED_TEST).then((generated) {
Expect.isTrue(generated.contains('main_closure(i)'),
'for-loop variable was boxed');
Siggi Cherem (dart-lang) 2017/06/30 22:02:10 while we are here, let's update the failure reason
Emily Fortuna 2017/06/30 23:48:10 Done.
}));
- asyncTest(() => compileAll(NEGATIVE_TEST).then((generated) {
+ asyncTest(() => compileAll(SHOULD_BE_BOXED_TEST).then((generated) {
+ Expect.isFalse(generated.contains('main_closure(i)'),
+ 'for-loop variable was not boxed');
+ }));
+ asyncTest(() => compileAll(ONLY_UPDATE_LOOP_VAR_TEST).then((generated) {
Expect.isFalse(generated.contains('main_closure(i)'),
'for-loop variable was not boxed');
+ Expect.isFalse(generated.contains(', _box_0.b = 3,'),
+ 'non for-loop captured variable should not be updated in loop');
}));
}
« pkg/compiler/lib/src/ssa/locals_handler.dart ('K') | « pkg/compiler/lib/src/ssa/locals_handler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698