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

Unified Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2151373002: Share LibrarySpecificUnits when possible (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Clean-up Created 4 years, 5 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
Index: pkg/analyzer/test/src/context/context_test.dart
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
index a851f55013cb35dd0e1293a146ce75ee23a92449..042ce4e228c41dace5d908687ef81fc52ac3d11a 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -1422,6 +1422,104 @@ Stream S = null;
}
}
+ void test_getLibrarySpecificUnit_definingCU_different() {
+ Source source1 = newSource('/lib1.dart');
+ Source source2 = newSource('/lib2.dart');
+ context.applyChanges(
+ new ChangeSet()..addedSource(source1)..addedSource(source2));
+ LibrarySpecificUnit lsu1 = context.getLibrarySpecificUnit(source1, source1);
+ expect(lsu1, isNotNull);
+ expect(lsu1.library, same(source1));
+ expect(lsu1.unit, same(source1));
+ LibrarySpecificUnit lsu2 = context.getLibrarySpecificUnit(source2, source2);
+ expect(lsu2, isNotNull);
+ expect(lsu2.library, same(source2));
+ expect(lsu2.unit, same(source2));
+ }
+
+ void test_getLibrarySpecificUnit_definingCU_explicit() {
+ Source source = newSource('/test.dart');
+ context.applyChanges(new ChangeSet()..addedSource(source));
+ LibrarySpecificUnit lsu1 = context.getLibrarySpecificUnit(source, source);
+ expect(lsu1, isNotNull);
+ expect(lsu1.library, same(source));
+ expect(lsu1.unit, same(source));
+ LibrarySpecificUnit lsu2 = context.getLibrarySpecificUnit(source, source);
+ expect(lsu2, same(lsu1));
+ }
+
+ void test_getLibrarySpecificUnit_definingCU_implicit() {
+ Source source = newSource('/test.dart');
+ LibrarySpecificUnit lsu1 = context.getLibrarySpecificUnit(source, source);
+ expect(lsu1, isNotNull);
+ expect(lsu1.library, same(source));
+ expect(lsu1.unit, same(source));
+ LibrarySpecificUnit lsu2 = context.getLibrarySpecificUnit(source, source);
+ expect(lsu2, equals(lsu1));
+ }
+
+ void test_getLibrarySpecificUnit_part_differentLibraries() {
+ Source library1 = newSource('/lib1.dart');
+ Source library2 = newSource('/lib2.dart');
+ Source part = newSource('/part.dart');
+ context.applyChanges(new ChangeSet()
+ ..addedSource(library1)
+ ..addedSource(library2)
+ ..addedSource(part));
+ LibrarySpecificUnit lsu1 = context.getLibrarySpecificUnit(library1, part);
+ expect(lsu1, isNotNull);
+ expect(lsu1.library, same(library1));
+ expect(lsu1.unit, same(part));
+ LibrarySpecificUnit lsu2 = context.getLibrarySpecificUnit(library2, part);
+ expect(lsu2, isNotNull);
+ expect(lsu2.library, same(library2));
+ expect(lsu2.unit, same(part));
+ }
+
+ void test_getLibrarySpecificUnit_part_differentParts() {
+ Source library = newSource('/lib.dart');
+ Source part1 = newSource('/part1.dart');
+ Source part2 = newSource('/part2.dart');
+ context.applyChanges(new ChangeSet()
+ ..addedSource(library)
+ ..addedSource(part1)
+ ..addedSource(part2));
+ LibrarySpecificUnit lsu1 = context.getLibrarySpecificUnit(library, part1);
+ expect(lsu1, isNotNull);
+ expect(lsu1.library, same(library));
+ expect(lsu1.unit, same(part1));
+ LibrarySpecificUnit lsu2 = context.getLibrarySpecificUnit(library, part2);
+ expect(lsu2, isNotNull);
+ expect(lsu2.library, same(library));
+ expect(lsu2.unit, same(part2));
+ }
+
+ void test_getLibrarySpecificUnit_part_explicit() {
+ Source library = newSource('/lib.dart');
+ Source part = newSource('/part.dart');
+ context
+ .applyChanges(new ChangeSet()..addedSource(library)..addedSource(part));
+ LibrarySpecificUnit lsu1 = context.getLibrarySpecificUnit(library, part);
+ expect(lsu1, isNotNull);
+ expect(lsu1.library, same(library));
+ expect(lsu1.unit, same(part));
+ LibrarySpecificUnit lsu2 = context.getLibrarySpecificUnit(library, part);
+ expect(lsu2, same(lsu1));
+ }
+
+ void test_getLibrarySpecificUnit_part_implicit() {
+ Source library = newSource('/lib.dart');
+ Source part = newSource('/part.dart');
+ LibrarySpecificUnit lsu1 = context.getLibrarySpecificUnit(library, part);
+ expect(lsu1, isNotNull);
+ expect(lsu1.library, same(library));
+ expect(lsu1.unit, same(part));
+ LibrarySpecificUnit lsu2 = context.getLibrarySpecificUnit(library, part);
+ expect(lsu2, isNotNull);
+ expect(lsu2.library, same(library));
+ expect(lsu2.unit, same(part));
+ }
+
void test_getLineInfo() {
Source source = addSource(
"/test.dart",
« no previous file with comments | « pkg/analyzer/test/src/context/cache_test.dart ('k') | pkg/analyzer/test/src/task/dart_work_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698