| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library analyzer.test.driver; | 5 library analyzer.test.driver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 provider.newFile(a, 'class A {}'); | 806 provider.newFile(a, 'class A {}'); |
| 807 provider.newFile(b, 'export "a.dart", class B {}'); | 807 provider.newFile(b, 'export "a.dart", class B {}'); |
| 808 provider.newFile(c, 'import "d.dart"; class C {}'); | 808 provider.newFile(c, 'import "d.dart"; class C {}'); |
| 809 provider.newFile(d, 'class D {}'); | 809 provider.newFile(d, 'class D {}'); |
| 810 | 810 |
| 811 driver.addFile(a); | 811 driver.addFile(a); |
| 812 driver.addFile(b); | 812 driver.addFile(b); |
| 813 driver.addFile(c); | 813 driver.addFile(c); |
| 814 // Don't add d.dart, it is referenced implicitly. | 814 // Don't add d.dart, it is referenced implicitly. |
| 815 | 815 |
| 816 void assertLibraryPaths( | 816 void assertDeclarations(List<TopLevelDeclarationInSource> declarations, |
| 817 List<TopLevelDeclarationInSource> declarations, List<String> expected) { | 817 List<String> expectedFiles, List<bool> expectedIsExported) { |
| 818 expect(declarations.map((l) => l.source.fullName), | 818 expect(expectedFiles, hasLength(expectedIsExported.length)); |
| 819 unorderedEquals(expected)); | 819 for (int i = 0; i < expectedFiles.length; i++) { |
| 820 expect(declarations, |
| 821 contains(predicate((TopLevelDeclarationInSource declaration) { |
| 822 return declaration.source.fullName == expectedFiles[i] && |
| 823 declaration.isExported == expectedIsExported[i]; |
| 824 }))); |
| 825 } |
| 820 } | 826 } |
| 821 | 827 |
| 822 assertLibraryPaths(await driver.getTopLevelNameDeclarations('A'), [a, b]); | 828 assertDeclarations( |
| 829 await driver.getTopLevelNameDeclarations('A'), [a, b], [false, true]); |
| 823 | 830 |
| 824 assertLibraryPaths(await driver.getTopLevelNameDeclarations('B'), [b]); | 831 assertDeclarations( |
| 832 await driver.getTopLevelNameDeclarations('B'), [b], [false]); |
| 825 | 833 |
| 826 assertLibraryPaths(await driver.getTopLevelNameDeclarations('C'), [c]); | 834 assertDeclarations( |
| 835 await driver.getTopLevelNameDeclarations('C'), [c], [false]); |
| 827 | 836 |
| 828 assertLibraryPaths(await driver.getTopLevelNameDeclarations('D'), [d]); | 837 assertDeclarations( |
| 838 await driver.getTopLevelNameDeclarations('D'), [d], [false]); |
| 829 | 839 |
| 830 assertLibraryPaths(await driver.getTopLevelNameDeclarations('X'), []); | 840 assertDeclarations(await driver.getTopLevelNameDeclarations('X'), [], []); |
| 831 } | 841 } |
| 832 | 842 |
| 833 test_knownFiles() async { | 843 test_knownFiles() async { |
| 834 var a = _p('/test/lib/a.dart'); | 844 var a = _p('/test/lib/a.dart'); |
| 835 var b = _p('/test/lib/b.dart'); | 845 var b = _p('/test/lib/b.dart'); |
| 836 | 846 |
| 837 provider.newFile( | 847 provider.newFile( |
| 838 a, | 848 a, |
| 839 r''' | 849 r''' |
| 840 import 'b.dart'; | 850 import 'b.dart'; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 String _p(String path) => provider.convertPath(path); | 1350 String _p(String path) => provider.convertPath(path); |
| 1341 | 1351 |
| 1342 Future<Null> _waitForIdle() async { | 1352 Future<Null> _waitForIdle() async { |
| 1343 await idleStatusMonitor.signal; | 1353 await idleStatusMonitor.signal; |
| 1344 } | 1354 } |
| 1345 | 1355 |
| 1346 static String _md5(String content) { | 1356 static String _md5(String content) { |
| 1347 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 1357 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 1348 } | 1358 } |
| 1349 } | 1359 } |
| OLD | NEW |