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

Unified Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 1209773002: SourceFactoryTest extraction. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | pkg/analyzer/test/generated/source_factory_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/all_the_rest_test.dart
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index a928617a39238b43ac6d762ca55b7f0ddf7b1796..9eafca63ab510449b0b33aeccaeb2747a3582a5b 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -74,7 +74,6 @@ main() {
}
runReflectiveTests(ReferenceFinderTest);
runReflectiveTests(SDKLibrariesReaderTest);
- runReflectiveTests(SourceFactoryTest);
runReflectiveTests(ToSourceVisitorTest);
runReflectiveTests(UriKindTest);
runReflectiveTests(StringScannerTest);
@@ -8260,97 +8259,6 @@ final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
}
}
-@reflectiveTest
-class SourceFactoryTest {
- void test_creation() {
- expect(new SourceFactory([]), isNotNull);
- }
- void test_fromEncoding_invalidUri() {
- SourceFactory factory = new SourceFactory([]);
- try {
- factory.fromEncoding("<:&%>");
- fail("Expected IllegalArgumentException");
- } on IllegalArgumentException {}
- }
- void test_fromEncoding_noResolver() {
- SourceFactory factory = new SourceFactory([]);
- try {
- factory.fromEncoding("foo:/does/not/exist.dart");
- fail("Expected IllegalArgumentException");
- } on IllegalArgumentException {}
- }
- void test_fromEncoding_valid() {
- String encoding = "file:///does/not/exist.dart";
- SourceFactory factory = new SourceFactory(
- [new UriResolver_SourceFactoryTest_test_fromEncoding_valid(encoding)]);
- expect(factory.fromEncoding(encoding), isNotNull);
- }
- void test_resolveUri_absolute() {
- UriResolver_absolute resolver = new UriResolver_absolute();
- SourceFactory factory = new SourceFactory([resolver]);
- factory.resolveUri(null, "dart:core");
- expect(resolver.invoked, isTrue);
- }
- void test_resolveUri_nonAbsolute_absolute() {
- SourceFactory factory =
- new SourceFactory([new UriResolver_nonAbsolute_absolute()]);
- String absolutePath = "/does/not/matter.dart";
- Source containingSource =
- new FileBasedSource(FileUtilities2.createFile("/does/not/exist.dart"));
- Source result = factory.resolveUri(containingSource, absolutePath);
- expect(result.fullName,
- FileUtilities2.createFile(absolutePath).getAbsolutePath());
- }
- void test_resolveUri_nonAbsolute_relative() {
- SourceFactory factory =
- new SourceFactory([new UriResolver_nonAbsolute_relative()]);
- Source containingSource =
- new FileBasedSource(FileUtilities2.createFile("/does/not/have.dart"));
- Source result = factory.resolveUri(containingSource, "exist.dart");
- expect(result.fullName,
- FileUtilities2.createFile("/does/not/exist.dart").getAbsolutePath());
- }
-
- void test_resolveUri_nonAbsolute_relative_package() {
- MemoryResourceProvider provider = new MemoryResourceProvider();
- Context context = provider.pathContext;
- String packagePath =
- context.joinAll([context.separator, 'path', 'to', 'package']);
- String libPath = context.joinAll([packagePath, 'lib']);
- String dirPath = context.joinAll([libPath, 'dir']);
- String firstPath = context.joinAll([dirPath, 'first.dart']);
- String secondPath = context.joinAll([dirPath, 'second.dart']);
-
- provider.newFolder(packagePath);
- Folder libFolder = provider.newFolder(libPath);
- provider.newFolder(dirPath);
- File firstFile = provider.newFile(firstPath, '');
- provider.newFile(secondPath, '');
-
- PackageMapUriResolver resolver =
- new PackageMapUriResolver(provider, {'package': [libFolder]});
- SourceFactory factory = new SourceFactory([resolver]);
- Source librarySource =
- firstFile.createSource(Uri.parse('package:package/dir/first.dart'));
-
- Source result = factory.resolveUri(librarySource, 'second.dart');
- expect(result, isNotNull);
- expect(result.fullName, secondPath);
- expect(result.uri.toString(), 'package:package/dir/second.dart');
- }
-
- void test_restoreUri() {
- JavaFile file1 = FileUtilities2.createFile("/some/file1.dart");
- JavaFile file2 = FileUtilities2.createFile("/some/file2.dart");
- Source source1 = new FileBasedSource(file1);
- Source source2 = new FileBasedSource(file2);
- Uri expected1 = parseUriWithException("file:///my_file.dart");
- SourceFactory factory =
- new SourceFactory([new UriResolver_restoreUri(source1, expected1)]);
- expect(factory.restoreUri(source1), same(expected1));
- expect(factory.restoreUri(source2), same(null));
- }
-}
@reflectiveTest
class StringScannerTest extends AbstractScannerTest {
@@ -8428,66 +8336,6 @@ class UriKindTest {
}
}
-class UriResolver_absolute extends UriResolver {
- bool invoked = false;
-
- UriResolver_absolute();
-
- @override
- Source resolveAbsolute(Uri uri) {
- invoked = true;
- return null;
- }
-}
-
-class UriResolver_nonAbsolute_absolute extends UriResolver {
- @override
- Source resolveAbsolute(Uri uri) {
- return new FileBasedSource(new JavaFile.fromUri(uri), uri);
- }
-}
-
-class UriResolver_nonAbsolute_relative extends UriResolver {
- @override
- Source resolveAbsolute(Uri uri) {
- return new FileBasedSource(new JavaFile.fromUri(uri), uri);
- }
-}
-
-class UriResolver_restoreUri extends UriResolver {
- Source source1;
-
- Uri expected1;
-
- UriResolver_restoreUri(this.source1, this.expected1);
-
- @override
- Source resolveAbsolute(Uri uri) => null;
-
- @override
- Uri restoreAbsolute(Source source) {
- if (identical(source, source1)) {
- return expected1;
- }
- return null;
- }
-}
-
-class UriResolver_SourceFactoryTest_test_fromEncoding_valid
- extends UriResolver {
- String encoding;
-
- UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding);
-
- @override
- Source resolveAbsolute(Uri uri) {
- if (uri.toString() == encoding) {
- return new TestSource();
- }
- return null;
- }
-}
-
/**
* Instances of `XmlValidator` traverse an [XmlNode] structure and validate the node
* hierarchy.
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/source_factory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698