| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:convert'; | 5 import 'dart:convert'; |
| 6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 7 | 7 |
| 8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
| 9 import 'package:analyzer/file_system/memory_file_system.dart'; | 9 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 10 import 'package:analyzer/source/package_map_resolver.dart'; | 10 import 'package:analyzer/source/package_map_resolver.dart'; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 provider.newFile( | 279 provider.newFile( |
| 280 a, | 280 a, |
| 281 r''' | 281 r''' |
| 282 library L; | 282 library L; |
| 283 part of L; | 283 part of L; |
| 284 '''); | 284 '''); |
| 285 FileState file = fileSystemState.getFileForPath(a); | 285 FileState file = fileSystemState.getFileForPath(a); |
| 286 expect(file.isPart, isFalse); | 286 expect(file.isPart, isFalse); |
| 287 } | 287 } |
| 288 | 288 |
| 289 test_getFileForPath_import_invalidUri() { |
| 290 String a = _p('/aaa/lib/a.dart'); |
| 291 String a1 = _p('/aaa/lib/a1.dart'); |
| 292 String a2 = _p('/aaa/lib/a2.dart'); |
| 293 String a3 = _p('/aaa/lib/a3.dart'); |
| 294 String content_a1 = r''' |
| 295 import 'package:aaa/a1.dart'; |
| 296 import '[invalid uri]'; |
| 297 |
| 298 export '[invalid uri]'; |
| 299 export 'package:aaa/a2.dart'; |
| 300 |
| 301 part 'a3.dart'; |
| 302 part '[invalid uri]'; |
| 303 '''; |
| 304 provider.newFile(a, content_a1); |
| 305 |
| 306 FileState file = fileSystemState.getFileForPath(a); |
| 307 |
| 308 expect(_excludeSdk(file.importedFiles), hasLength(1)); |
| 309 expect(file.importedFiles[0].path, a1); |
| 310 expect(file.importedFiles[0].uri, Uri.parse('package:aaa/a1.dart')); |
| 311 expect(file.importedFiles[0].source, isNotNull); |
| 312 |
| 313 expect(_excludeSdk(file.exportedFiles), hasLength(1)); |
| 314 expect(file.exportedFiles[0].path, a2); |
| 315 expect(file.exportedFiles[0].uri, Uri.parse('package:aaa/a2.dart')); |
| 316 expect(file.exportedFiles[0].source, isNotNull); |
| 317 |
| 318 expect(_excludeSdk(file.partedFiles), hasLength(1)); |
| 319 expect(file.partedFiles[0].path, a3); |
| 320 expect(file.partedFiles[0].uri, Uri.parse('package:aaa/a3.dart')); |
| 321 expect(file.partedFiles[0].source, isNotNull); |
| 322 } |
| 323 |
| 289 test_getFileForPath_library() { | 324 test_getFileForPath_library() { |
| 290 String a1 = _p('/aaa/lib/a1.dart'); | 325 String a1 = _p('/aaa/lib/a1.dart'); |
| 291 String a2 = _p('/aaa/lib/a2.dart'); | 326 String a2 = _p('/aaa/lib/a2.dart'); |
| 292 String a3 = _p('/aaa/lib/a3.dart'); | 327 String a3 = _p('/aaa/lib/a3.dart'); |
| 293 String a4 = _p('/aaa/lib/a4.dart'); | 328 String a4 = _p('/aaa/lib/a4.dart'); |
| 294 String b1 = _p('/bbb/lib/b1.dart'); | 329 String b1 = _p('/bbb/lib/b1.dart'); |
| 295 String b2 = _p('/bbb/lib/b2.dart'); | 330 String b2 = _p('/bbb/lib/b2.dart'); |
| 296 String content_a1 = r''' | 331 String content_a1 = r''' |
| 297 import 'package:aaa/a2.dart'; | 332 import 'package:aaa/a2.dart'; |
| 298 import 'package:bbb/b1.dart'; | 333 import 'package:bbb/b1.dart'; |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 String _p(String path) => provider.convertPath(path); | 766 String _p(String path) => provider.convertPath(path); |
| 732 | 767 |
| 733 static String _md5(String content) { | 768 static String _md5(String content) { |
| 734 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 769 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 735 } | 770 } |
| 736 } | 771 } |
| 737 | 772 |
| 738 class _GeneratedUriResolverMock extends TypedMock implements UriResolver {} | 773 class _GeneratedUriResolverMock extends TypedMock implements UriResolver {} |
| 739 | 774 |
| 740 class _SourceMock extends TypedMock implements Source {} | 775 class _SourceMock extends TypedMock implements Source {} |
| OLD | NEW |