| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'package:analyzer/error/listener.dart'; |
| 6 import 'package:analyzer/src/generated/parser.dart'; |
| 7 import 'package:analyzer/src/summary/summarize_ast.dart'; |
| 8 import 'package:front_end/src/base/file_repository.dart'; |
| 9 import 'package:front_end/src/base/library_info.dart'; |
| 10 import 'package:front_end/src/libraries_reader.dart'; |
| 11 import 'package:front_end/src/scanner/errors.dart'; |
| 12 import 'package:front_end/src/scanner/reader.dart'; |
| 13 import 'package:front_end/src/scanner/scanner.dart'; |
| 14 import 'package:test/test.dart'; |
| 15 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 16 |
| 17 main() { |
| 18 defineReflectiveSuite(() { |
| 19 defineReflectiveTests(FileRepositoryTest); |
| 20 }); |
| 21 } |
| 22 |
| 23 /// Generic URI resolver tests which do not depend on the particular path |
| 24 /// context in use. |
| 25 @reflectiveTest |
| 26 class FileRepositoryTest { |
| 27 final fileRepository = new FileRepository(); |
| 28 |
| 29 test_contentsForPath() { |
| 30 var path1 = |
| 31 fileRepository.store(Uri.parse('file:///foo/bar.dart'), 'contents1'); |
| 32 var path2 = |
| 33 fileRepository.store(Uri.parse('package:foo/bar.dart'), 'contents2'); |
| 34 expect(fileRepository.contentsForPath(path1), 'contents1'); |
| 35 expect(fileRepository.contentsForPath(path2), 'contents2'); |
| 36 } |
| 37 |
| 38 test_pathForUri() { |
| 39 var uri1 = Uri.parse('file:///foo/bar.dart'); |
| 40 var path1 = fileRepository.store(uri1, 'contents1'); |
| 41 var uri2 = Uri.parse('package:foo/bar.dart'); |
| 42 var path2 = fileRepository.store(uri2, 'contents2'); |
| 43 expect(fileRepository.pathForUri(uri1), path1); |
| 44 expect(fileRepository.pathForUri(uri2), path2); |
| 45 } |
| 46 |
| 47 test_store() { |
| 48 var uri = Uri.parse('file:///foo/bar.dart'); |
| 49 var path = fileRepository.store(uri, 'contents1'); |
| 50 expect(path, endsWith('.dart')); |
| 51 expect(fileRepository.contentsForPath(path), 'contents1'); |
| 52 expect(fileRepository.store(uri, 'contents2'), path); |
| 53 expect(fileRepository.contentsForPath(path), 'contents2'); |
| 54 } |
| 55 |
| 56 test_uriForPath() { |
| 57 var uri1 = Uri.parse('file:///foo/bar.dart'); |
| 58 var path1 = fileRepository.store(uri1, 'contents1'); |
| 59 var uri2 = Uri.parse('package:foo/bar.dart'); |
| 60 var path2 = fileRepository.store(uri2, 'contents2'); |
| 61 expect(fileRepository.uriForPath(path1), uri1); |
| 62 expect(fileRepository.uriForPath(path2), uri2); |
| 63 } |
| 64 } |
| OLD | NEW |