OLD | NEW |
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 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
9 import 'package:analyzer/source/package_map_resolver.dart'; | 9 import 'package:analyzer/source/package_map_resolver.dart'; |
10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 provider.newFile(pkgFileB, 'library lib_b;'); | 155 provider.newFile(pkgFileB, 'library lib_b;'); |
156 PackageMapUriResolver resolver = | 156 PackageMapUriResolver resolver = |
157 new PackageMapUriResolver(provider, <String, List<Folder>>{ | 157 new PackageMapUriResolver(provider, <String, List<Folder>>{ |
158 'pkgA': [provider.getResource('/pkgA/lib/')], | 158 'pkgA': [provider.getResource('/pkgA/lib/')], |
159 'pkgB': [provider.getResource('/pkgB/lib/')] | 159 'pkgB': [provider.getResource('/pkgB/lib/')] |
160 }); | 160 }); |
161 { | 161 { |
162 Source source = _createFileSource('/pkgA/lib/libA.dart'); | 162 Source source = _createFileSource('/pkgA/lib/libA.dart'); |
163 Uri uri = resolver.restoreAbsolute(source); | 163 Uri uri = resolver.restoreAbsolute(source); |
164 expect(uri, isNotNull); | 164 expect(uri, isNotNull); |
165 expect(uri.path, 'package:pkgA/libA.dart'); | 165 expect(uri.toString(), 'package:pkgA/libA.dart'); |
166 } | 166 } |
167 { | 167 { |
168 Source source = _createFileSource('/pkgB/lib/src/libB.dart'); | 168 Source source = _createFileSource('/pkgB/lib/src/libB.dart'); |
169 Uri uri = resolver.restoreAbsolute(source); | 169 Uri uri = resolver.restoreAbsolute(source); |
170 expect(uri, isNotNull); | 170 expect(uri, isNotNull); |
171 expect(uri.path, 'package:pkgB/src/libB.dart'); | 171 expect(uri.toString(), 'package:pkgB/src/libB.dart'); |
172 } | 172 } |
173 { | 173 { |
174 Source source = _createFileSource('/no/such/file'); | 174 Source source = _createFileSource('/no/such/file'); |
175 Uri uri = resolver.restoreAbsolute(source); | 175 Uri uri = resolver.restoreAbsolute(source); |
176 expect(uri, isNull); | 176 expect(uri, isNull); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 Source _createFileSource(String path) { | 180 Source _createFileSource(String path) { |
181 return new NonExistingSource(path, UriKind.FILE_URI); | 181 return new NonExistingSource(path, UriKind.FILE_URI); |
182 } | 182 } |
183 } | 183 } |
OLD | NEW |