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

Side by Side Diff: pkg/analyzer/test/source/package_map_resolver_test.dart

Issue 428303004: Breaking changes in 'analyzer' package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename Source.resolveRelative to resolveRelativeUri, soften version constraints Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/test/services/test_utils.dart ('k') | pkg/code_transformers/lib/src/dart_sdk.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.source.package_map_resolver; 5 library test.source.package_map_resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 10 import 'package:analyzer/file_system/memory_file_system.dart';
11 import 'package:analyzer/source/package_map_resolver.dart'; 11 import 'package:analyzer/source/package_map_resolver.dart';
12 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
13 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
14 14
15 15
16 main() { 16 main() {
17 groupSep = ' | '; 17 groupSep = ' | ';
18 group('PackageMapUriResolverTest', () { 18 group('PackageMapUriResolverTest', () {
19 test('fromEncoding_nonPackage', () {
20 new _PackageMapUriResolverTest().test_fromEncoding_nonPackage();
21 });
22 test('fromEncoding_package', () {
23 new _PackageMapUriResolverTest().test_fromEncoding_package();
24 });
25 test('isPackageUri', () { 19 test('isPackageUri', () {
26 new _PackageMapUriResolverTest().test_isPackageUri(); 20 new _PackageMapUriResolverTest().test_isPackageUri();
27 }); 21 });
28 test('isPackageUri_null_scheme', () { 22 test('isPackageUri_null_scheme', () {
29 new _PackageMapUriResolverTest().test_isPackageUri_null_scheme(); 23 new _PackageMapUriResolverTest().test_isPackageUri_null_scheme();
30 }); 24 });
31 test('isPackageUri_other_scheme', () { 25 test('isPackageUri_other_scheme', () {
32 new _PackageMapUriResolverTest().test_isPackageUri_other_scheme(); 26 new _PackageMapUriResolverTest().test_isPackageUri_other_scheme();
33 }); 27 });
34 test('resolve_multiple_folders', () { 28 test('resolve_multiple_folders', () {
(...skipping 22 matching lines...) Expand all
57 new _PackageMapUriResolverTest().test_restoreAbsolute(); 51 new _PackageMapUriResolverTest().test_restoreAbsolute();
58 }); 52 });
59 }); 53 });
60 } 54 }
61 55
62 56
63 class _PackageMapUriResolverTest { 57 class _PackageMapUriResolverTest {
64 static HashMap EMPTY_MAP = new HashMap<String, List<Folder>>(); 58 static HashMap EMPTY_MAP = new HashMap<String, List<Folder>>();
65 MemoryResourceProvider provider = new MemoryResourceProvider(); 59 MemoryResourceProvider provider = new MemoryResourceProvider();
66 60
67 void test_fromEncoding_nonPackage() {
68 UriResolver resolver = new PackageMapUriResolver(provider, EMPTY_MAP);
69 Uri uri = Uri.parse('file:/does/not/exist.dart');
70 Source result = resolver.fromEncoding(UriKind.DART_URI, uri);
71 expect(result, isNull);
72 }
73
74 void test_fromEncoding_package() {
75 UriResolver resolver = new PackageMapUriResolver(provider, EMPTY_MAP);
76 Uri uri = Uri.parse('package:/does/not/exist.dart');
77 Source result = resolver.fromEncoding(UriKind.PACKAGE_URI, uri);
78 expect(result, isNotNull);
79 expect(result.fullName, '/does/not/exist.dart');
80 }
81
82 void test_isPackageUri() { 61 void test_isPackageUri() {
83 Uri uri = Uri.parse('package:test/test.dart'); 62 Uri uri = Uri.parse('package:test/test.dart');
84 expect(uri.scheme, 'package'); 63 expect(uri.scheme, 'package');
85 expect(PackageMapUriResolver.isPackageUri(uri), isTrue); 64 expect(PackageMapUriResolver.isPackageUri(uri), isTrue);
86 } 65 }
87 66
88 void test_isPackageUri_null_scheme() { 67 void test_isPackageUri_null_scheme() {
89 Uri uri = Uri.parse('foo.dart'); 68 Uri uri = Uri.parse('foo.dart');
90 expect(uri.scheme, ''); 69 expect(uri.scheme, '');
91 expect(PackageMapUriResolver.isPackageUri(uri), isFalse); 70 expect(PackageMapUriResolver.isPackageUri(uri), isFalse);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 Source source = _createFileSource('/no/such/file'); 196 Source source = _createFileSource('/no/such/file');
218 Uri uri = resolver.restoreAbsolute(source); 197 Uri uri = resolver.restoreAbsolute(source);
219 expect(uri, isNull); 198 expect(uri, isNull);
220 } 199 }
221 } 200 }
222 201
223 Source _createFileSource(String path) { 202 Source _createFileSource(String path) {
224 return new NonExistingSource(path, UriKind.FILE_URI); 203 return new NonExistingSource(path, UriKind.FILE_URI);
225 } 204 }
226 } 205 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/services/test_utils.dart ('k') | pkg/code_transformers/lib/src/dart_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698