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

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

Issue 935453007: When translating from file to URI, make sure translation is reversible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
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 '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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 expect(uri, isNotNull); 170 expect(uri, isNotNull);
171 expect(uri.toString(), '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 void test_restoreAmbiguous() {
181 const file1 = '/foo1/lib/bar.dart';
182 const file2 = '/foo2/lib/bar.dart';
183 provider.newFile(file1, 'library bar');
184 provider.newFile(file2, 'library bar');
185 PackageMapUriResolver resolver =
186 new PackageMapUriResolver(provider, <String, List<Folder>>{
187 'foo': [
188 provider.getResource('/foo1/lib'),
189 provider.getResource('/foo2/lib')]
190 });
191 // Restoring file1 should yield a package URI, and that package URI should
192 // resolve back to file1.
193 Source source1 = _createFileSource(file1);
194 Uri uri1 = resolver.restoreAbsolute(source1);
195 expect(uri1.toString(), 'package:foo/bar.dart');
196 expect(resolver.resolveAbsolute(uri1).fullName, file1);
197 // Restoring file2 should not yield a package URI, because there is no URI
198 // that resolves to file2.
199 Source source2 = _createFileSource(file2);
200 expect(resolver.restoreAbsolute(source2), isNull);
201 }
202
180 Source _createFileSource(String path) { 203 Source _createFileSource(String path) {
181 return new NonExistingSource(path, UriKind.FILE_URI); 204 return new NonExistingSource(path, UriKind.FILE_URI);
182 } 205 }
183 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698