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

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

Issue 2999003002: Add more tested features to closure_test (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/captured_variable.dart
diff --git a/tests/compiler/dart2js/closure/data/captured_variable.dart b/tests/compiler/dart2js/closure/data/captured_variable.dart
new file mode 100644
index 0000000000000000000000000000000000000000..430864ee7920681ac6da2c05dae34b96a3b852d9
--- /dev/null
+++ b/tests/compiler/dart2js/closure/data/captured_variable.dart
@@ -0,0 +1,45 @@
+// 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.
+
+/*readParameterInClosure:*/
+readParameterInClosure(/**/ parameter) {
+ /*captured=[parameter],free=[parameter]*/ func() => parameter;
+ return func;
+}
+
+/*writeParameterInClosure:boxed=[parameter],captured=[parameter],requiresBox*/
+writeParameterInClosure(/*boxed*/ parameter) {
+ /*boxed=[parameter],captured=[parameter],free=[box,parameter]*/ func() {
+ parameter = 42;
+ }
+
+ ;
Emily Fortuna 2017/08/16 00:55:11 why the weird whitespace with this semicolon?
Johnni Winther 2017/08/16 07:30:19 That's how dartfmt puts a ; after a function decla
+ return func;
+}
+
+/*readLocalInClosure:*/
+readLocalInClosure(/**/ parameter) {
+ var /**/ local = parameter;
+ /*captured=[local],free=[local]*/ func() => local;
+ return func;
+}
+
+/*writeLocalInClosure:boxed=[local],captured=[local],requiresBox*/
+writeLocalInClosure(/**/ parameter) {
+ // ignore: UNUSED_LOCAL_VARIABLE
+ var /*boxed*/ local = parameter;
+ /*boxed=[local],captured=[local],free=[box,local]*/ func() {
+ local = 42;
+ }
+
+ ;
Emily Fortuna 2017/08/16 00:55:11 here too
+ return func;
+}
+
+main() {
+ readParameterInClosure(null);
+ writeParameterInClosure(null);
+ readLocalInClosure(null);
+ writeLocalInClosure(null);
+}
« no previous file with comments | « tests/compiler/dart2js/closure/closure_test.dart ('k') | tests/compiler/dart2js/closure/data/parameter_in_try.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698