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

Unified Diff: pkg/front_end/test/src/base/file_repository_test.dart

Issue 2645923002: Create a "file repository" data structure to help interface analyzer and front_end code. (Closed)
Patch Set: Created 3 years, 11 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/front_end/lib/src/incremental_resolved_ast_generator_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/src/base/file_repository_test.dart
diff --git a/pkg/front_end/test/src/base/file_repository_test.dart b/pkg/front_end/test/src/base/file_repository_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..de033b093a55640d78582f09841739ef9d5b43aa
--- /dev/null
+++ b/pkg/front_end/test/src/base/file_repository_test.dart
@@ -0,0 +1,64 @@
+// Copyright (c) 2017, 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/error/listener.dart';
+import 'package:analyzer/src/generated/parser.dart';
+import 'package:analyzer/src/summary/summarize_ast.dart';
+import 'package:front_end/src/base/file_repository.dart';
+import 'package:front_end/src/base/library_info.dart';
+import 'package:front_end/src/libraries_reader.dart';
+import 'package:front_end/src/scanner/errors.dart';
+import 'package:front_end/src/scanner/reader.dart';
+import 'package:front_end/src/scanner/scanner.dart';
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(FileRepositoryTest);
+ });
+}
+
+/// Generic URI resolver tests which do not depend on the particular path
+/// context in use.
+@reflectiveTest
+class FileRepositoryTest {
+ final fileRepository = new FileRepository();
+
+ test_contentsForPath() {
+ var path1 =
+ fileRepository.store(Uri.parse('file:///foo/bar.dart'), 'contents1');
+ var path2 =
+ fileRepository.store(Uri.parse('package:foo/bar.dart'), 'contents2');
+ expect(fileRepository.contentsForPath(path1), 'contents1');
+ expect(fileRepository.contentsForPath(path2), 'contents2');
+ }
+
+ test_pathForUri() {
+ var uri1 = Uri.parse('file:///foo/bar.dart');
+ var path1 = fileRepository.store(uri1, 'contents1');
+ var uri2 = Uri.parse('package:foo/bar.dart');
+ var path2 = fileRepository.store(uri2, 'contents2');
+ expect(fileRepository.pathForUri(uri1), path1);
+ expect(fileRepository.pathForUri(uri2), path2);
+ }
+
+ test_store() {
+ var uri = Uri.parse('file:///foo/bar.dart');
+ var path = fileRepository.store(uri, 'contents1');
+ expect(path, endsWith('.dart'));
+ expect(fileRepository.contentsForPath(path), 'contents1');
+ expect(fileRepository.store(uri, 'contents2'), path);
+ expect(fileRepository.contentsForPath(path), 'contents2');
+ }
+
+ test_uriForPath() {
+ var uri1 = Uri.parse('file:///foo/bar.dart');
+ var path1 = fileRepository.store(uri1, 'contents1');
+ var uri2 = Uri.parse('package:foo/bar.dart');
+ var path2 = fileRepository.store(uri2, 'contents2');
+ expect(fileRepository.uriForPath(path1), uri1);
+ expect(fileRepository.uriForPath(path2), uri2);
+ }
+}
« no previous file with comments | « pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698