Chromium Code Reviews| 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); |
| +} |