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

Unified Diff: tests/compiler/dart2js/closure/data/nested_closures.dart

Issue 3003963002: Add more tests for closures and change closure indexing to be by FunctionExpression or FunctionDecl… (Closed)
Patch Set: . Created 3 years, 4 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/closure/data/nested_closures.dart
diff --git a/tests/compiler/dart2js/closure/data/nested_closures.dart b/tests/compiler/dart2js/closure/data/nested_closures.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4ba90f5bac2485cf4946018182a0b0cea1029fa0
--- /dev/null
+++ b/tests/compiler/dart2js/closure/data/nested_closures.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2017, 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.
+
+/// Test boxing/captures for nested closures.
+
+/*useOne:box=box0,boxed=[b1]*/ useOne(/*boxed*/ b1) {
+ /*box=box1,boxed=[b2],free=[b1,box0]*/ () {
+ var /*boxed*/ b2 = (b1 = 1);
+
+ /*free=[b2,box1]*/ () {
+ return (b2 = 2);
+ };
+
+ return b2;
+ };
+ return b1;
+}
+
+/*useBoth:box=box0,boxed=[b1]*/ useBoth(/*boxed*/ b1) {
+ /*box=box1,boxed=[b2],free=[b1,box0]*/ () {
+ var /*boxed*/ b2 = (b1 = 1);
+
+ /*free=[b1,b2,box0,box1]*/ () {
+ return b1 + (b2 = 2);
+ };
+
+ return b2;
+ };
+ return b1;
+}
+
+/*useMany:box=box0,boxed=[b1,b2,b3]*/ useMany(c1, /*boxed*/ b1) {
+ var /*boxed*/ b2 = 2;
+ var /*boxed*/ b3 = 3;
+ var c2 = 2;
+ var c3 = 3;
+ /*box=box1,boxed=[b4],free=[b1,b2,b3,box0,c1,c2,c3]*/ () {
+ var c4 = c1 + c2 + c3;
+ var /*boxed*/ b4 = (b1 = 1) + (b2 = 2) + (b3 = 3);
+
+ /*free=[b1,b2,b4,box0,box1,c4]*/ () {
+ return c4 + (b1 = 1) + (b2 = 2) + (b4 = 4);
+ };
+
+ return b4;
+ };
+ return b1 + b2 + b3 + c1 + c2 + c3;
+}
+
+main() {
+ useOne(1);
+ useBoth(1);
+ useMany(1, 2);
+}

Powered by Google App Engine
This is Rietveld 408576698