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

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

Issue 1073993004: Revert "Issue 23133. Fix for restoring 'package:' uris on Windows." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/lib/source/package_map_resolver.dart ('k') | no next file » | 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 '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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 expect(uri, isNotNull); 169 expect(uri, isNotNull);
170 expect(uri.toString(), 'package:pkgB/src/libB.dart'); 170 expect(uri.toString(), 'package:pkgB/src/libB.dart');
171 } 171 }
172 { 172 {
173 Source source = _createFileSource('/no/such/file'); 173 Source source = _createFileSource('/no/such/file');
174 Uri uri = resolver.restoreAbsolute(source); 174 Uri uri = resolver.restoreAbsolute(source);
175 expect(uri, isNull); 175 expect(uri, isNull);
176 } 176 }
177 } 177 }
178 178
179 void test_restoreAbsolute_ambiguous() { 179 void test_restoreAmbiguous() {
180 const file1 = '/foo1/lib/bar.dart'; 180 const file1 = '/foo1/lib/bar.dart';
181 const file2 = '/foo2/lib/bar.dart'; 181 const file2 = '/foo2/lib/bar.dart';
182 provider.newFile(file1, 'library bar'); 182 provider.newFile(file1, 'library bar');
183 provider.newFile(file2, 'library bar'); 183 provider.newFile(file2, 'library bar');
184 PackageMapUriResolver resolver = new PackageMapUriResolver(provider, 184 PackageMapUriResolver resolver = new PackageMapUriResolver(provider,
185 <String, List<Folder>>{ 185 <String, List<Folder>>{
186 'foo': [ 186 'foo': [
187 provider.getResource('/foo1/lib'), 187 provider.getResource('/foo1/lib'),
188 provider.getResource('/foo2/lib') 188 provider.getResource('/foo2/lib')
189 ] 189 ]
190 }); 190 });
191 // Restoring file1 should yield a package URI, and that package URI should 191 // Restoring file1 should yield a package URI, and that package URI should
192 // resolve back to file1. 192 // resolve back to file1.
193 Source source1 = _createFileSource(file1); 193 Source source1 = _createFileSource(file1);
194 Uri uri1 = resolver.restoreAbsolute(source1); 194 Uri uri1 = resolver.restoreAbsolute(source1);
195 expect(uri1.toString(), 'package:foo/bar.dart'); 195 expect(uri1.toString(), 'package:foo/bar.dart');
196 expect(resolver.resolveAbsolute(uri1).fullName, file1); 196 expect(resolver.resolveAbsolute(uri1).fullName, file1);
197 // Restoring file2 should not yield a package URI, because there is no URI 197 // Restoring file2 should not yield a package URI, because there is no URI
198 // that resolves to file2. 198 // that resolves to file2.
199 Source source2 = _createFileSource(file2); 199 Source source2 = _createFileSource(file2);
200 expect(resolver.restoreAbsolute(source2), isNull); 200 expect(resolver.restoreAbsolute(source2), isNull);
201 } 201 }
202 202
203 void test_restoreAbsolute_longestMatch() { 203 void test_restoreLongestMatch() {
204 const file1 = '/foo1/bar1/lib.dart'; 204 const file1 = '/foo1/bar1/lib.dart';
205 const file2 = '/foo2/bar2/lib.dart'; 205 const file2 = '/foo2/bar2/lib.dart';
206 provider.newFile(file1, 'library lib'); 206 provider.newFile(file1, 'library lib');
207 provider.newFile(file2, 'library lib'); 207 provider.newFile(file2, 'library lib');
208 PackageMapUriResolver resolver = new PackageMapUriResolver(provider, 208 PackageMapUriResolver resolver = new PackageMapUriResolver(provider,
209 <String, List<Folder>>{ 209 <String, List<Folder>>{
210 'pkg1': [ 210 'pkg1': [
211 provider.getResource('/foo1'), 211 provider.getResource('/foo1'),
212 provider.getResource('/foo2/bar2') 212 provider.getResource('/foo2/bar2')
213 ], 213 ],
(...skipping 11 matching lines...) Expand all
225 // for the file path (/foo2/bar2) is longer than pkg2's match (/foo2). 225 // for the file path (/foo2/bar2) is longer than pkg2's match (/foo2).
226 Source source2 = _createFileSource(file2); 226 Source source2 = _createFileSource(file2);
227 Uri uri2 = resolver.restoreAbsolute(source2); 227 Uri uri2 = resolver.restoreAbsolute(source2);
228 expect(uri2.toString(), 'package:pkg1/lib.dart'); 228 expect(uri2.toString(), 'package:pkg1/lib.dart');
229 } 229 }
230 230
231 Source _createFileSource(String path) { 231 Source _createFileSource(String path) {
232 return new NonExistingSource(path, UriKind.FILE_URI); 232 return new NonExistingSource(path, UriKind.FILE_URI);
233 } 233 }
234 } 234 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/source/package_map_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698