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

Unified Diff: tests/compiler/dart2js/closure/closure_test.dart

Issue 2950493002: Add closure_test (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
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | tests/compiler/dart2js/closure/data/parameter_in_try.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/closure/closure_test.dart
diff --git a/tests/compiler/dart2js/closure/closure_test.dart b/tests/compiler/dart2js/closure/closure_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..acf11a06e5571017ae5d6122b43410ba858959f8
--- /dev/null
+++ b/tests/compiler/dart2js/closure/closure_test.dart
@@ -0,0 +1,60 @@
+// 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.
+
+import 'dart:io';
+import 'package:async_helper/async_helper.dart';
+import 'package:compiler/src/closure.dart';
+import 'package:compiler/src/compiler.dart';
+import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
+import 'package:compiler/src/elements/elements.dart';
+import 'package:compiler/src/tree/nodes.dart';
+import '../equivalence/id_equivalence.dart';
+import '../equivalence/id_equivalence_helper.dart';
+
+main() {
+ asyncTest(() async {
+ Directory dataDir = new Directory.fromUri(Platform.script.resolve('data'));
+ await for (FileSystemEntity entity in dataDir.list()) {
+ print('Checking ${entity.uri}');
+ String annotatedCode = await new File.fromUri(entity.uri).readAsString();
+ await checkCode(annotatedCode, checkClosureData);
+ }
+ });
+}
+
+void checkClosureData(
+ Compiler compiler, Map<Id, String> expectedMap, MemberElement member) {
+ new ClosureChecker(compiler.reporter, expectedMap, member.resolvedAst,
+ compiler.closureDataLookup as ClosureDataLookup<Node>)
+ .check();
+}
+
+class ClosureChecker extends AbstractResolvedAstChecker {
+ final ClosureDataLookup<Node> closureDataLookup;
+ final ClosureRepresentationInfo info;
+
+ ClosureChecker(DiagnosticReporter reporter, Map<Id, String> expectedMap,
+ ResolvedAst resolvedAst, this.closureDataLookup)
+ : this.info =
+ closureDataLookup.getClosureRepresentationInfo(resolvedAst.element),
+ super(reporter, expectedMap, resolvedAst);
+
+ @override
+ String computeNodeValue(Node node, [AstElement element]) {
+ if (element != null && element.isLocal) {
+ LocalElement local = element;
+ StringBuffer sb = new StringBuffer();
+ if (info.variableIsUsedInTryOrSync(local)) {
+ sb.write('inTry');
+ }
+ return sb.toString();
+ }
+ return null;
+ }
+
+ @override
+ String computeElementValue(AstElement element) {
+ return null;
+ }
+}
« no previous file with comments | « pkg/compiler/lib/src/compiler.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