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

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

Issue 1807673006: Initial LibraryBundleCache implementation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: tweaks 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/incremental_cache.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..99ab3d3ba2c7064bfa6f970a828bd81ea93ad9b8
--- /dev/null
+++ b/pkg/analyzer/test/src/summary/incremental_cache_test.dart
@@ -0,0 +1,73 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/src/summary/idl.dart';
+import 'package:analyzer/src/summary/incremental_cache.dart';
+import 'package:unittest/unittest.dart';
+
+import '../../reflective_tests.dart';
+import '../abstract_single_unit.dart';
+
+main() {
+ groupSep = ' | ';
+ runReflectiveTests(LibraryBundleCacheTest);
+}
+
+/**
+ * TODO(scheglov) write more tests for invalidation.
+ */
+@reflectiveTest
+class LibraryBundleCacheTest extends AbstractSingleUnitTest {
+ Folder cacheFolder;
+ LibraryBundleCache cache;
+
+ @override
+ void setUp() {
+ super.setUp();
+ cacheFolder = resourceProvider.newFolder('/cache');
+ cache = new LibraryBundleCache('pid.tmp', cacheFolder, context, <int>[]);
+ }
+
+ void test_readBundle_emptyCache() {
+ resolveTestUnit('main() {}');
+ // the cache is empty, no bundle
+ PackageBundle bundle = cache.readBundle(testSource);
+ expect(bundle, 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_importLib() {
+ addSource('/a.dart', '// 1');
+ resolveTestUnit(r'''
+import 'a.dart';
+main() {}
+''');
+ cache.putLibrary(testLibraryElement);
+ // has bundle
+ 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_withoutDependencies() {
+ resolveTestUnit('main() {}');
+ cache.putLibrary(testLibraryElement);
+ // has bundle
+ PackageBundle bundle = cache.readBundle(testSource);
+ expect(bundle, isNotNull);
+ }
+}
« no previous file with comments | « pkg/analyzer/lib/src/summary/incremental_cache.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698