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

Unified Diff: pkg/analyzer/test/src/summary/incremental_cache_test.dart

Issue 1814013004: Add source kind to the incremental cache. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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/summary/incremental_cache_test.dart
diff --git a/pkg/analyzer/test/src/summary/incremental_cache_test.dart b/pkg/analyzer/test/src/summary/incremental_cache_test.dart
index 99ab3d3ba2c7064bfa6f970a828bd81ea93ad9b8..5824cd3c3f14cfea59e8c139e8d4c41d1503d2b3 100644
--- a/pkg/analyzer/test/src/summary/incremental_cache_test.dart
+++ b/pkg/analyzer/test/src/summary/incremental_cache_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/incremental_cache.dart';
import 'package:unittest/unittest.dart';
@@ -30,6 +31,32 @@ class LibraryBundleCacheTest extends AbstractSingleUnitTest {
cache = new LibraryBundleCache('pid.tmp', cacheFolder, context, <int>[]);
}
+ void test_getSourceKind_library() {
+ resolveTestUnit(r'''
+main() {}
+''');
+ cache.putLibrary(testLibraryElement);
+ expect(cache.getSourceKind(testSource), SourceKind.LIBRARY);
+ }
+
+ void test_getSourceKind_notCached() {
+ resolveTestUnit(r'''
+main() {}
+''');
+ expect(cache.getSourceKind(testSource), isNull);
+ }
+
+ void test_getSourceKind_part() {
+ Source partSource = addSource('/foo.dart', 'part of lib;');
+ resolveTestUnit(r'''
+library lib;
+part 'foo.dart';
+''');
+ cache.putLibrary(testLibraryElement);
+ expect(cache.getSourceKind(testSource), SourceKind.LIBRARY);
+ expect(cache.getSourceKind(partSource), SourceKind.PART);
+ }
+
void test_readBundle_emptyCache() {
resolveTestUnit('main() {}');
// the cache is empty, no bundle
@@ -37,15 +64,19 @@ class LibraryBundleCacheTest extends AbstractSingleUnitTest {
expect(bundle, isNull);
}
- void test_readBundle_importSdk() {
+ void test_readBundle_exportLib() {
+ addSource('/a.dart', '// 1');
resolveTestUnit(r'''
-import 'dart:async';
+export 'a.dart';
main() {}
''');
cache.putLibrary(testLibraryElement);
// has bundle
- PackageBundle bundle = cache.readBundle(testSource);
- expect(bundle, isNotNull);
+ expect(cache.readBundle(testSource), isNotNull);
+ // update a.dart, no bundle
+ cache.clearInternalCaches();
+ resourceProvider.updateFile('/a.dart', '// 2');
+ expect(cache.readBundle(testSource), isNull);
}
void test_readBundle_importLib() {
@@ -63,6 +94,17 @@ main() {}
expect(cache.readBundle(testSource), isNull);
}
+ void test_readBundle_importSdk() {
+ resolveTestUnit(r'''
+import 'dart:async';
+main() {}
+''');
+ cache.putLibrary(testLibraryElement);
+ // has bundle
+ PackageBundle bundle = cache.readBundle(testSource);
+ expect(bundle, isNotNull);
+ }
+
void test_readBundle_withoutDependencies() {
resolveTestUnit('main() {}');
cache.putLibrary(testLibraryElement);

Powered by Google App Engine
This is Rietveld 408576698