OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 package_config.parse_write_test; | 5 library package_config.parse_write_test; |
6 | 6 |
7 import "package:package_config/packages_file.dart"; | 7 import "package:package_config/packages_file.dart"; |
8 import "package:test/test.dart"; | 8 import "package:test/test.dart"; |
9 | 9 |
10 main() { | 10 main() { |
(...skipping 16 matching lines...) Expand all Loading... |
27 expect(resultMap, map); | 27 expect(resultMap, map); |
28 }); | 28 }); |
29 | 29 |
30 test("write with base .packages file", () { | 30 test("write with base .packages file", () { |
31 var content = writeToString(map, baseUri: packagesFile).codeUnits; | 31 var content = writeToString(map, baseUri: packagesFile).codeUnits; |
32 var resultMap = parse(content, packagesFile); | 32 var resultMap = parse(content, packagesFile); |
33 expect(resultMap, map); | 33 expect(resultMap, map); |
34 }); | 34 }); |
35 }); | 35 }); |
36 } | 36 } |
| 37 |
37 var lowerDir = baseDir.resolve("path3/path4/"); | 38 var lowerDir = baseDir.resolve("path3/path4/"); |
38 var higherDir = baseDir.resolve("../"); | 39 var higherDir = baseDir.resolve("../"); |
39 var parallelDir = baseDir.resolve("../path3/"); | 40 var parallelDir = baseDir.resolve("../path3/"); |
40 var rootDir = baseDir.resolve("/"); | 41 var rootDir = baseDir.resolve("/"); |
41 var fileDir = Uri.parse("file:///path1/part2/"); | 42 var fileDir = Uri.parse("file:///path1/part2/"); |
42 var httpDir = Uri.parse("http://example.com/path1/path2/"); | 43 var httpDir = Uri.parse("http://example.com/path1/path2/"); |
43 var otherDir = Uri.parse("other:/path1/path2/"); | 44 var otherDir = Uri.parse("other:/path1/path2/"); |
44 | 45 |
45 roundTripTest("empty", {}); | 46 roundTripTest("empty", {}); |
46 roundTripTest("lower directory", {"foo": lowerDir}); | 47 roundTripTest("lower directory", {"foo": lowerDir}); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 "# comment line 1\n# comment line 2\n# comment line 3\n"; | 80 "# comment line 1\n# comment line 2\n# comment line 3\n"; |
80 expect(result, startsWith(expectedComment)); | 81 expect(result, startsWith(expectedComment)); |
81 }); | 82 }); |
82 } | 83 } |
83 | 84 |
84 String writeToString(Map<String, Uri> map, {Uri baseUri, String comment}) { | 85 String writeToString(Map<String, Uri> map, {Uri baseUri, String comment}) { |
85 var buffer = new StringBuffer(); | 86 var buffer = new StringBuffer(); |
86 write(buffer, map, baseUri: baseUri, comment: comment); | 87 write(buffer, map, baseUri: baseUri, comment: comment); |
87 return buffer.toString(); | 88 return buffer.toString(); |
88 } | 89 } |
OLD | NEW |