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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:io';
6 import 'package:async_helper/async_helper.dart';
7 import 'package:compiler/src/closure.dart';
8 import 'package:compiler/src/compiler.dart';
9 import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
10 import 'package:compiler/src/elements/elements.dart';
11 import 'package:compiler/src/tree/nodes.dart';
12 import '../equivalence/id_equivalence.dart';
13 import '../equivalence/id_equivalence_helper.dart';
14
15 main() {
16 asyncTest(() async {
17 Directory dataDir = new Directory.fromUri(Platform.script.resolve('data'));
18 await for (FileSystemEntity entity in dataDir.list()) {
19 print('Checking ${entity.uri}');
20 String annotatedCode = await new File.fromUri(entity.uri).readAsString();
21 await checkCode(annotatedCode, checkClosureData);
22 }
23 });
24 }
25
26 void checkClosureData(
27 Compiler compiler, Map<Id, String> expectedMap, MemberElement member) {
28 new ClosureChecker(compiler.reporter, expectedMap, member.resolvedAst,
29 compiler.closureDataLookup as ClosureDataLookup<Node>)
30 .check();
31 }
32
33 class ClosureChecker extends AbstractResolvedAstChecker {
34 final ClosureDataLookup<Node> closureDataLookup;
35 final ClosureRepresentationInfo info;
36
37 ClosureChecker(DiagnosticReporter reporter, Map<Id, String> expectedMap,
38 ResolvedAst resolvedAst, this.closureDataLookup)
39 : this.info =
40 closureDataLookup.getClosureRepresentationInfo(resolvedAst.element),
41 super(reporter, expectedMap, resolvedAst);
42
43 @override
44 String computeNodeValue(Node node, [AstElement element]) {
45 if (element != null && element.isLocal) {
46 LocalElement local = element;
47 StringBuffer sb = new StringBuffer();
48 if (info.variableIsUsedInTryOrSync(local)) {
49 sb.write('inTry');
50 }
51 return sb.toString();
52 }
53 return null;
54 }
55
56 @override
57 String computeElementValue(AstElement element) {
58 return null;
59 }
60 }
OLDNEW
« 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