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

Unified Diff: pkg/analyzer/test/src/dart/analysis/file_state_test.dart

Issue 2543263002: Use Map(s) for top-level declarations. (Closed)
Patch Set: Created 4 years 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
Index: pkg/analyzer/test/src/dart/analysis/file_state_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index 8a3a8da40a8a1e98c0b170b106f8051661e67557..bb45ad1dd7f4432e7d2dc481c1b3096bf51bd83d 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -73,8 +73,9 @@ export 'a.dart';
class B {}
''');
FileState file = fileSystemState.getFileForPath(b);
- List<TopLevelDeclaration> declarations = file.exportedTopLevelDeclarations;
- expect(declarations.map((t) => t.name), unorderedEquals(['A', 'B']));
+ Map<String, TopLevelDeclaration> declarations =
+ file.exportedTopLevelDeclarations;
+ expect(declarations.keys, unorderedEquals(['A', 'B']));
}
test_exportedTopLevelDeclarations_export2_show() {
@@ -162,9 +163,10 @@ export 'a.dart';
int V;
''');
FileState file = fileSystemState.getFileForPath(b);
- List<TopLevelDeclaration> declarations = file.exportedTopLevelDeclarations;
- expect(declarations.map((t) => t.name), unorderedEquals(['V']));
- expect(declarations.single.kind, TopLevelDeclarationKind.variable);
+ Map<String, TopLevelDeclaration> declarations =
+ file.exportedTopLevelDeclarations;
+ expect(declarations.keys, unorderedEquals(['V']));
+ expect(declarations['V'].kind, TopLevelDeclarationKind.variable);
}
test_exportedTopLevelDeclarations_export_show() {
@@ -499,16 +501,13 @@ set _V3(_) {}
''');
FileState file = fileSystemState.getFileForPath(path);
- List<TopLevelDeclaration> declarations = file.topLevelDeclarations;
+ Map<String, TopLevelDeclaration> declarations = file.topLevelDeclarations;
void assertHas(String name, TopLevelDeclarationKind kind) {
- expect(
- declarations,
- contains(predicate(
- (TopLevelDeclaration t) => t.name == name && t.kind == kind)));
+ expect(declarations[name]?.kind, kind);
}
- expect(declarations.map((t) => t.name),
+ expect(declarations.keys,
unorderedEquals(['C', 'F', 'E', 'f', 'V1', 'V2', 'V3', 'V4']));
assertHas('C', TopLevelDeclarationKind.type);
assertHas('F', TopLevelDeclarationKind.type);
@@ -636,8 +635,9 @@ set _V3(_) {}
void _assertExportedTopLevelDeclarations(String path, List<String> expected) {
FileState file = fileSystemState.getFileForPath(path);
- List<TopLevelDeclaration> declarations = file.exportedTopLevelDeclarations;
- expect(declarations.map((t) => t.name), unorderedEquals(expected));
+ Map<String, TopLevelDeclaration> declarations =
+ file.exportedTopLevelDeclarations;
+ expect(declarations.keys, unorderedEquals(expected));
}
void _assertFilesWithoutTransitiveFiles(List<FileState> expected) {

Powered by Google App Engine
This is Rietveld 408576698