| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
| 7 import 'package:compiler/src/compiler.dart'; | 7 import 'package:compiler/src/compiler.dart'; |
| 8 import 'package:compiler/src/commandline_options.dart'; | 8 import 'package:compiler/src/commandline_options.dart'; |
| 9 import 'package:compiler/src/elements/elements.dart'; | 9 import 'package:compiler/src/elements/elements.dart'; |
| 10 import 'package:compiler/src/kernel/kernel.dart'; | 10 import 'package:compiler/src/kernel/kernel.dart'; |
| 11 import 'package:compiler/src/tree/nodes.dart' as ast; | 11 import 'package:compiler/src/tree/nodes.dart' as ast; |
| 12 import 'package:expect/expect.dart'; | 12 import 'package:expect/expect.dart'; |
| 13 import 'package:kernel/ast.dart' as ir; | 13 import 'package:kernel/ast.dart' as ir; |
| 14 import 'inference_test_helper.dart'; | 14 import '../equivalence/id_equivalence.dart'; |
| 15 import 'enumerator.dart'; | 15 import '../equivalence/id_equivalence_helper.dart'; |
| 16 |
| 17 const List<String> dataDirectories = const <String>[ |
| 18 '../inference/data', |
| 19 ]; |
| 16 | 20 |
| 17 main() { | 21 main() { |
| 18 asyncTest(() async { | 22 asyncTest(() async { |
| 19 Directory dataDir = new Directory.fromUri(Platform.script.resolve('data')); | 23 for (String path in dataDirectories) { |
| 20 await for (FileSystemEntity entity in dataDir.list()) { | 24 Directory dataDir = new Directory.fromUri(Platform.script.resolve(path)); |
| 21 print('Checking ${entity.uri}'); | 25 await for (FileSystemEntity entity in dataDir.list()) { |
| 22 String annotatedCode = await new File.fromUri(entity.uri).readAsString(); | 26 print('Checking ${entity.uri}'); |
| 23 await checkCode(annotatedCode, checkMemberEquivalence, | 27 String annotatedCode = |
| 24 options: [Flags.useKernel]); | 28 await new File.fromUri(entity.uri).readAsString(); |
| 29 await checkCode(annotatedCode, checkMemberEquivalence, |
| 30 options: [Flags.useKernel]); |
| 31 } |
| 25 } | 32 } |
| 26 }); | 33 }); |
| 27 } | 34 } |
| 28 | 35 |
| 29 /// Check that the ids in [expectedMap] map to equivalent nodes/elements in | 36 /// Check that the ids in [expectedMap] map to equivalent nodes/elements in |
| 30 /// the AST and kernel IR. | 37 /// the AST and kernel IR. |
| 31 void checkMemberEquivalence( | 38 void checkMemberEquivalence( |
| 32 Compiler compiler, Map<Id, String> expectedMap, MemberElement member) { | 39 Compiler compiler, Map<Id, String> expectedMap, MemberElement member) { |
| 33 ResolvedAst resolvedAst = member.resolvedAst; | 40 ResolvedAst resolvedAst = member.resolvedAst; |
| 34 if (resolvedAst.kind != ResolvedAstKind.PARSED) return; | 41 if (resolvedAst.kind != ResolvedAstKind.PARSED) return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 65 }); | 72 }); |
| 66 astMap.forEach((Id id, ast.Node astNode) { | 73 astMap.forEach((Id id, ast.Node astNode) { |
| 67 ir.Node irNode = irMap[id]; | 74 ir.Node irNode = irMap[id]; |
| 68 Expect.equals( | 75 Expect.equals( |
| 69 kernel.nodeToAst[irNode], astNode, "Node mismatch on $id = $astNode"); | 76 kernel.nodeToAst[irNode], astNode, "Node mismatch on $id = $astNode"); |
| 70 expectedMap.remove(id); | 77 expectedMap.remove(id); |
| 71 irMap.remove(id); | 78 irMap.remove(id); |
| 72 }); | 79 }); |
| 73 Expect.isTrue(irMap.isEmpty, "Extra IR ids: $irMap"); | 80 Expect.isTrue(irMap.isEmpty, "Extra IR ids: $irMap"); |
| 74 } | 81 } |
| OLD | NEW |