Index: tests/compiler/dart2js/closure/data/mutations.dart |
diff --git a/tests/compiler/dart2js/closure/data/mutations.dart b/tests/compiler/dart2js/closure/data/mutations.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ca31e8f762438de668464062ac41ccde362c6b01 |
--- /dev/null |
+++ b/tests/compiler/dart2js/closure/data/mutations.dart |
@@ -0,0 +1,66 @@ |
+// 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 that captured variables are boxed regardless of where they are mutated. |
+ |
+/*mutateUnused:*/ |
+mutateUnused() { |
+ var local; |
+ /**/ () { |
+ // Use nothing. |
+ }; |
+ local = 42; |
+ return local; |
+} |
+ |
+/*mutateInClosure:box=box0,boxed=[local]*/ |
+mutateInClosure() { |
+ var /*boxed*/ local; |
+ /*free=[box0,local]*/ () { |
+ local = 42; |
+ }; |
+ return local; |
+} |
+ |
+/*mutateOutsideClosure:box=box0,boxed=[local]*/ |
+mutateOutsideClosure() { |
+ var /*boxed*/ local; |
+ /*free=[box0,local]*/ () { |
+ print(local); |
+ }; |
+ local = 42; |
+ return local; |
+} |
+ |
+/*mutateInOtherClosure:box=box0,boxed=[local]*/ |
+mutateInOtherClosure() { |
+ var /*boxed*/ local; |
+ /*free=[box0,local]*/ () { |
+ print(local); |
+ }; |
+ /*free=[box0,local]*/ () { |
+ local = 42; |
+ }; |
+ return local; |
+} |
+ |
+/*mutateInNestedClosure:box=box0,boxed=[local]*/ |
+mutateInNestedClosure() { |
+ var /*boxed*/ local; |
+ /*free=[box0,local]*/ () { |
+ print(local); |
+ /*free=[box0,local]*/ () { |
+ local = 42; |
+ }; |
+ }; |
+ return local; |
+} |
+ |
+main() { |
+ mutateUnused(); |
+ mutateInClosure(); |
+ mutateOutsideClosure(); |
+ mutateInOtherClosure(); |
+ mutateInNestedClosure(); |
+} |