| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 roundTripTest("empty", {}); | 45 roundTripTest("empty", {}); |
| 46 roundTripTest("lower directory", {"foo": lowerDir}); | 46 roundTripTest("lower directory", {"foo": lowerDir}); |
| 47 roundTripTest("higher directory", {"foo": higherDir}); | 47 roundTripTest("higher directory", {"foo": higherDir}); |
| 48 roundTripTest("parallel directory", {"foo": parallelDir}); | 48 roundTripTest("parallel directory", {"foo": parallelDir}); |
| 49 roundTripTest("same directory", {"foo": baseDir}); | 49 roundTripTest("same directory", {"foo": baseDir}); |
| 50 roundTripTest("root directory", {"foo": rootDir}); | 50 roundTripTest("root directory", {"foo": rootDir}); |
| 51 roundTripTest("file directory", {"foo": fileDir}); | 51 roundTripTest("file directory", {"foo": fileDir}); |
| 52 roundTripTest("http directory", {"foo": httpDir}); | 52 roundTripTest("http directory", {"foo": httpDir}); |
| 53 roundTripTest("other scheme directory", {"foo": otherDir}); | 53 roundTripTest("other scheme directory", {"foo": otherDir}); |
| 54 roundTripTest("multiple same-type directories", | 54 roundTripTest("multiple same-type directories", |
| 55 {"foo": lowerDir, "bar": higherDir, "baz": parallelDir}); | 55 {"foo": lowerDir, "bar": higherDir, "baz": parallelDir}); |
| 56 roundTripTest("multiple scheme directories", | 56 roundTripTest("multiple scheme directories", |
| 57 {"foo": fileDir, "bar": httpDir, "baz": otherDir}); | 57 {"foo": fileDir, "bar": httpDir, "baz": otherDir}); |
| 58 roundTripTest("multiple scheme directories and mutliple same type", | 58 roundTripTest("multiple scheme directories and mutliple same type", { |
| 59 {"foo": fileDir, "bar": httpDir, "baz": otherDir, | 59 "foo": fileDir, |
| 60 "qux": lowerDir, "hip": higherDir, "dep": parallelDir}); | 60 "bar": httpDir, |
| 61 "baz": otherDir, |
| 62 "qux": lowerDir, |
| 63 "hip": higherDir, |
| 64 "dep": parallelDir |
| 65 }); |
| 61 }); | 66 }); |
| 62 } | 67 } |
| 63 | 68 |
| 64 testBase("file:///base1/base2/"); | 69 testBase("file:///base1/base2/"); |
| 65 testBase("http://example.com/base1/base2/"); | 70 testBase("http://example.com/base1/base2/"); |
| 66 testBase("other:/base1/base2/"); | 71 testBase("other:/base1/base2/"); |
| 67 | 72 |
| 68 // Check that writing adds the comment. | 73 // Check that writing adds the comment. |
| 69 test("write preserves comment", () { | 74 test("write preserves comment", () { |
| 70 var comment = "comment line 1\ncomment line 2\ncomment line 3"; | 75 var comment = "comment line 1\ncomment line 2\ncomment line 3"; |
| 71 var result = writeToString({}, comment: comment); | 76 var result = writeToString({}, comment: comment); |
| 72 // Comment with "# " before each line and "\n" after last. | 77 // Comment with "# " before each line and "\n" after last. |
| 73 var expectedComment = | 78 var expectedComment = |
| 74 "# comment line 1\n# comment line 2\n# comment line 3\n"; | 79 "# comment line 1\n# comment line 2\n# comment line 3\n"; |
| 75 expect(result, startsWith(expectedComment)); | 80 expect(result, startsWith(expectedComment)); |
| 76 }); | 81 }); |
| 77 } | 82 } |
| 78 | 83 |
| 79 String writeToString(Map map, {Uri baseUri, String comment}) { | 84 String writeToString(Map<String, Uri> map, {Uri baseUri, String comment}) { |
| 80 var buffer = new StringBuffer(); | 85 var buffer = new StringBuffer(); |
| 81 write(buffer, map, baseUri: baseUri, comment: comment); | 86 write(buffer, map, baseUri: baseUri, comment: comment); |
| 82 return buffer.toString(); | 87 return buffer.toString(); |
| 83 } | 88 } |
| OLD | NEW |