dartfmt
diff --git a/lib/discovery.dart b/lib/discovery.dart
index 8e42af7..10dbb8e 100644
--- a/lib/discovery.dart
+++ b/lib/discovery.dart
@@ -28,7 +28,7 @@
/// resolution file, for example one specified using a `--packages`
/// command-line parameter.
Future<Packages> loadPackagesFile(Uri packagesFile,
- {Future<List<int>> loader(Uri uri)}) {
+ {Future<List<int>> loader(Uri uri)}) {
Packages parseBytes(List<int> bytes) {
Map<String, Uri> packageMap = pkgfile.parse(bytes, packagesFile);
return new MapPackages(packageMap);
@@ -43,7 +43,6 @@
return loader(packagesFile).then(parseBytes);
}
-
/// Create a [Packages] object for a package directory.
///
/// The [packagesDir] URI should refer to a directory.
@@ -63,7 +62,6 @@
return new NonFilePackagesDirectoryPackages(packagesDir);
}
-
/// Discover the package configuration for a Dart script.
///
/// The [baseUri] points to either the Dart script or its directory.
@@ -93,7 +91,7 @@
/// The content should be a UTF-8 encoded `.packages` file, and must return an
/// error future if loading fails for any reason.
Future<Packages> findPackages(Uri baseUri,
- {Future<List<int>> loader(Uri unsupportedUri)}) {
+ {Future<List<int>> loader(Uri unsupportedUri)}) {
if (baseUri.scheme == "file") {
return new Future<Packages>.sync(() => findPackagesFromFile(baseUri));
} else if (loader != null) {
@@ -191,7 +189,7 @@
/// of the requested `.packages` file as bytes, which will be assumed to be
/// UTF-8 encoded.
Future<Packages> findPackagesFromNonFile(Uri nonFileUri,
- {Future<List<int>> loader(Uri name)}) {
+ {Future<List<int>> loader(Uri name)}) {
if (loader == null) loader = _httpGet;
Uri packagesFileUri = nonFileUri.resolve(".packages");
return loader(packagesFileUri).then((List<int> fileBytes) {
diff --git a/lib/discovery_analysis.dart b/lib/discovery_analysis.dart
index af4df07..6d4b9ed 100644
--- a/lib/discovery_analysis.dart
+++ b/lib/discovery_analysis.dart
@@ -41,7 +41,7 @@
/// Look up the [PackageContext] that applies to a specific directory.
///
/// The directory must be inside [directory].
- PackageContext operator[](Directory directory);
+ PackageContext operator [](Directory directory);
/// A map from directory to package resolver.
///
@@ -57,7 +57,7 @@
/// directory of `directory`. If there is, its corresponding `Packages` object
/// should be provided as `root`.
static PackageContext findAll(Directory directory,
- {Packages root: Packages.noPackages}) {
+ {Packages root: Packages.noPackages}) {
if (!directory.existsSync()) {
throw new ArgumentError("Directory not found: $directory");
}
@@ -93,8 +93,7 @@
}
findRoots(directory);
// If the root is not itself context root, add a the wrapper context.
- if (contexts.length == 1 &&
- contexts[0].directory == directory) {
+ if (contexts.length == 1 && contexts[0].directory == directory) {
return contexts[0];
}
return new _PackageContext(directory, root, contexts);
@@ -120,7 +119,7 @@
return result;
}
- PackageContext operator[](Directory directory) {
+ PackageContext operator [](Directory directory) {
String path = directory.path;
if (!path.startsWith(this.directory.path)) {
throw new ArgumentError("Not inside $path: $directory");
diff --git a/lib/packages.dart b/lib/packages.dart
index dbaa06d..890f448 100644
--- a/lib/packages.dart
+++ b/lib/packages.dart
@@ -17,7 +17,6 @@
/// One such case is if the packages are resolved relative to a
/// `packages/` directory available over HTTP.
abstract class Packages {
-
/// A [Packages] resolver containing no packages.
///
/// This constant object is returned by [find] above if no
diff --git a/lib/packages_file.dart b/lib/packages_file.dart
index f30781d..93ccd3c 100644
--- a/lib/packages_file.dart
+++ b/lib/packages_file.dart
@@ -84,7 +84,7 @@
/// All the keys of [packageMapping] must be valid package names,
/// and the values must be URIs that do not have the `package:` scheme.
void write(StringSink output, Map<String, Uri> packageMapping,
- {Uri baseUri, String comment}) {
+ {Uri baseUri, String comment}) {
if (baseUri != null && !baseUri.isAbsolute) {
throw new ArgumentError.value(baseUri, "baseUri", "Must be absolute");
}
diff --git a/lib/src/packages_impl.dart b/lib/src/packages_impl.dart
index e85f755..fa9115f 100644
--- a/lib/src/packages_impl.dart
+++ b/lib/src/packages_impl.dart
@@ -18,13 +18,13 @@
Uri resolve(Uri packageUri, {Uri notFound(Uri packageUri)}) {
String packageName = checkValidPackageUri(packageUri);
if (notFound != null) return notFound(packageUri);
- throw new ArgumentError.value(packageUri, "packageUri",
- 'No package named "$packageName"');
+ throw new ArgumentError.value(
+ packageUri, "packageUri", 'No package named "$packageName"');
}
Iterable<String> get packages => new Iterable<String>.generate(0);
- Map<String, Uri> asMap() => const<String,Uri>{};
+ Map<String, Uri> asMap() => const <String, Uri>{};
}
/// Base class for [Packages] implementations.
@@ -38,8 +38,8 @@
Uri packageBase = getBase(packageName);
if (packageBase == null) {
if (notFound != null) return notFound(packageUri);
- throw new ArgumentError.value(packageUri, "packageUri",
- 'No package named "$packageName"');
+ throw new ArgumentError.value(
+ packageUri, "packageUri", 'No package named "$packageName"');
}
String packagePath = packageUri.path.substring(packageName.length + 1);
return packageBase.resolve(packagePath);
diff --git a/lib/src/packages_io_impl.dart b/lib/src/packages_io_impl.dart
index 21b61fd..db39bdb 100644
--- a/lib/src/packages_io_impl.dart
+++ b/lib/src/packages_io_impl.dart
@@ -17,12 +17,13 @@
FilePackagesDirectoryPackages(this._packageDir);
Uri getBase(String packageName) =>
- new Uri.file(path.join(_packageDir.path, packageName, '.'));
+ new Uri.file(path.join(_packageDir.path, packageName, '.'));
Iterable<String> _listPackageNames() {
- return _packageDir.listSync()
- .where((e) => e is Directory)
- .map((e) => path.basename(e.path));
+ return _packageDir
+ .listSync()
+ .where((e) => e is Directory)
+ .map((e) => path.basename(e.path));
}
Iterable<String> get packages => _listPackageNames();
diff --git a/lib/src/util.dart b/lib/src/util.dart
index badf640..f1e1afd 100644
--- a/lib/src/util.dart
+++ b/lib/src/util.dart
@@ -43,29 +43,29 @@
/// Validate that a Uri is a valid package:URI.
String checkValidPackageUri(Uri packageUri) {
if (packageUri.scheme != "package") {
- throw new ArgumentError.value(packageUri, "packageUri",
- "Not a package: URI");
+ throw new ArgumentError.value(
+ packageUri, "packageUri", "Not a package: URI");
}
if (packageUri.hasAuthority) {
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package URIs must not have a host part");
+ throw new ArgumentError.value(
+ packageUri, "packageUri", "Package URIs must not have a host part");
}
if (packageUri.hasQuery) {
// A query makes no sense if resolved to a file: URI.
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package URIs must not have a query part");
+ throw new ArgumentError.value(
+ packageUri, "packageUri", "Package URIs must not have a query part");
}
if (packageUri.hasFragment) {
// We could leave the fragment after the URL when resolving,
// but it would be odd if "package:foo/foo.dart#1" and
// "package:foo/foo.dart#2" were considered different libraries.
// Keep the syntax open in case we ever get multiple libraries in one file.
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package URIs must not have a fragment part");
+ throw new ArgumentError.value(
+ packageUri, "packageUri", "Package URIs must not have a fragment part");
}
if (packageUri.path.startsWith('/')) {
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package URIs must not start with a '/'");
+ throw new ArgumentError.value(
+ packageUri, "packageUri", "Package URIs must not start with a '/'");
}
int firstSlash = packageUri.path.indexOf('/');
if (firstSlash == -1) {
@@ -76,8 +76,8 @@
int badIndex = _findInvalidCharacter(packageName);
if (badIndex >= 0) {
if (packageName.isEmpty) {
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package names mus be non-empty");
+ throw new ArgumentError.value(
+ packageUri, "packageUri", "Package names mus be non-empty");
}
if (badIndex == packageName.length) {
throw new ArgumentError.value(packageUri, "packageUri",
@@ -90,8 +90,8 @@
// Printable character.
badChar = "'${packageName[badIndex]}' ($badChar)";
}
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package names must not contain $badChar");
+ throw new ArgumentError.value(
+ packageUri, "packageUri", "Package names must not contain $badChar");
}
return packageName;
}
diff --git a/test/discovery_analysis_test.dart b/test/discovery_analysis_test.dart
index f33a4a8..0a28767 100644
--- a/test/discovery_analysis_test.dart
+++ b/test/discovery_analysis_test.dart
@@ -13,12 +13,14 @@
import "package:test/test.dart";
main() {
- fileTest("basic",
- {".packages": packagesFile,
- "foo": {".packages": packagesFile},
- "bar": {"packages": {"foo": {}, "bar":{}, "baz": {}}},
- "baz": {}},
- (Directory directory) {
+ fileTest("basic", {
+ ".packages": packagesFile,
+ "foo": {".packages": packagesFile},
+ "bar": {
+ "packages": {"foo": {}, "bar": {}, "baz": {}}
+ },
+ "baz": {}
+ }, (Directory directory) {
var dirUri = new Uri.directory(directory.path);
PackageContext ctx = PackageContext.findAll(directory);
PackageContext root = ctx[directory];
@@ -32,13 +34,13 @@
PackageContext bar = ctx[sub(directory, "bar")];
validatePackagesDir(bar.packages, dirUri.resolve("bar/"));
PackageContext barbar = ctx[sub(barDir, "bar")];
- expect(barbar, same(bar)); // inherited.
+ expect(barbar, same(bar)); // inherited.
PackageContext baz = ctx[sub(directory, "baz")];
- expect(baz, same(root)); // inherited.
+ expect(baz, same(root)); // inherited.
var map = ctx.asMap();
expect(map.keys.map((dir) => dir.path),
- unorderedEquals([directory.path, fooDir.path, barDir.path]));
+ unorderedEquals([directory.path, fooDir.path, barDir.path]));
});
}
@@ -56,11 +58,11 @@
void validatePackagesFile(Packages resolver, Uri location) {
expect(resolver, isNotNull);
expect(resolver.resolve(pkg("foo", "bar/baz")),
- equals(Uri.parse("file:///dart/packages/foo/bar/baz")));
+ equals(Uri.parse("file:///dart/packages/foo/bar/baz")));
expect(resolver.resolve(pkg("bar", "baz/qux")),
- equals(Uri.parse("http://example.com/dart/packages/bar/baz/qux")));
+ equals(Uri.parse("http://example.com/dart/packages/bar/baz/qux")));
expect(resolver.resolve(pkg("baz", "qux/foo")),
- equals(location.resolve("packages/baz/qux/foo")));
+ equals(location.resolve("packages/baz/qux/foo")));
expect(resolver.packages, unorderedEquals(["foo", "bar", "baz"]));
}
@@ -68,11 +70,11 @@
// Expect three packages: foo, bar and baz
expect(resolver, isNotNull);
expect(resolver.resolve(pkg("foo", "bar/baz")),
- equals(location.resolve("packages/foo/bar/baz")));
+ equals(location.resolve("packages/foo/bar/baz")));
expect(resolver.resolve(pkg("bar", "baz/qux")),
- equals(location.resolve("packages/bar/baz/qux")));
+ equals(location.resolve("packages/bar/baz/qux")));
expect(resolver.resolve(pkg("baz", "qux/foo")),
- equals(location.resolve("packages/baz/qux/foo")));
+ equals(location.resolve("packages/baz/qux/foo")));
if (location.scheme == "file") {
expect(resolver.packages, unorderedEquals(["foo", "bar", "baz"]));
} else {
@@ -95,9 +97,8 @@
/// Description is a map, each key is a file entry. If the value is a map,
/// it's a sub-dir, otherwise it's a file and the value is the content
/// as a string.
-void fileTest(String name,
- Map description,
- Future fileTest(Directory directory)) {
+void fileTest(
+ String name, Map description, Future fileTest(Directory directory)) {
group("file-test", () {
Directory tempDir = Directory.systemTemp.createTempSync("file-test");
setUp(() {
diff --git a/test/discovery_test.dart b/test/discovery_test.dart
index 4f780c2..97b7bbf 100644
--- a/test/discovery_test.dart
+++ b/test/discovery_test.dart
@@ -21,11 +21,11 @@
void validatePackagesFile(Packages resolver, Uri location) {
expect(resolver, isNotNull);
expect(resolver.resolve(pkg("foo", "bar/baz")),
- equals(Uri.parse("file:///dart/packages/foo/bar/baz")));
+ equals(Uri.parse("file:///dart/packages/foo/bar/baz")));
expect(resolver.resolve(pkg("bar", "baz/qux")),
- equals(Uri.parse("http://example.com/dart/packages/bar/baz/qux")));
+ equals(Uri.parse("http://example.com/dart/packages/bar/baz/qux")));
expect(resolver.resolve(pkg("baz", "qux/foo")),
- equals(location.resolve("packages/baz/qux/foo")));
+ equals(location.resolve("packages/baz/qux/foo")));
expect(resolver.packages, unorderedEquals(["foo", "bar", "baz"]));
}
@@ -33,11 +33,11 @@
// Expect three packages: foo, bar and baz
expect(resolver, isNotNull);
expect(resolver.resolve(pkg("foo", "bar/baz")),
- equals(location.resolve("packages/foo/bar/baz")));
+ equals(location.resolve("packages/foo/bar/baz")));
expect(resolver.resolve(pkg("bar", "baz/qux")),
- equals(location.resolve("packages/bar/baz/qux")));
+ equals(location.resolve("packages/bar/baz/qux")));
expect(resolver.resolve(pkg("baz", "qux/foo")),
- equals(location.resolve("packages/baz/qux/foo")));
+ equals(location.resolve("packages/baz/qux/foo")));
if (location.scheme == "file") {
expect(resolver.packages, unorderedEquals(["foo", "bar", "baz"]));
} else {
@@ -45,7 +45,6 @@
}
}
-
Uri pkg(String packageName, String packagePath) {
var path;
if (packagePath.startsWith('/')) {
@@ -57,11 +56,11 @@
}
main() {
- generalTest(".packages",
- {".packages": packagesFile,
- "script.dart": "main(){}",
- "packages": {"shouldNotBeFound": {}}},
- (Uri location) async {
+ generalTest(".packages", {
+ ".packages": packagesFile,
+ "script.dart": "main(){}",
+ "packages": {"shouldNotBeFound": {}}
+ }, (Uri location) async {
Packages resolver;
resolver = await findPackages(location);
validatePackagesFile(resolver, location);
@@ -76,36 +75,36 @@
validatePackagesFile(resolver, location);
});
- generalTest("packages/",
- {"packages": { "foo": {}, "bar": {}, "baz": {}},
- "script.dart": "main(){}"},
- (Uri location) async {
+ generalTest("packages/", {
+ "packages": {"foo": {}, "bar": {}, "baz": {}},
+ "script.dart": "main(){}"
+ }, (Uri location) async {
Packages resolver;
bool isFile = (location.scheme == "file");
resolver = await findPackages(location);
validatePackagesDir(resolver, location);
resolver = await findPackages(location.resolve("script.dart"));
validatePackagesDir(resolver, location);
- var specificDiscovery = isFile
- ? findPackagesFromFile
- : findPackagesFromNonFile;
+ var specificDiscovery =
+ isFile ? findPackagesFromFile : findPackagesFromNonFile;
resolver = await specificDiscovery(location);
validatePackagesDir(resolver, location);
resolver = await specificDiscovery(location.resolve("script.dart"));
validatePackagesDir(resolver, location);
});
- generalTest("underscore packages",
- {"packages": {"_foo": {}}},
- (Uri location) async {
+ generalTest("underscore packages", {
+ "packages": {"_foo": {}}
+ }, (Uri location) async {
Packages resolver = await findPackages(location);
expect(resolver.resolve(pkg("_foo", "foo.dart")),
- equals(location.resolve("packages/_foo/foo.dart")));
+ equals(location.resolve("packages/_foo/foo.dart")));
});
- fileTest(".packages recursive",
- {".packages": packagesFile, "subdir": {"script.dart": "main(){}"}},
- (Uri location) async {
+ fileTest(".packages recursive", {
+ ".packages": packagesFile,
+ "subdir": {"script.dart": "main(){}"}
+ }, (Uri location) async {
Packages resolver;
resolver = await findPackages(location.resolve("subdir/"));
validatePackagesFile(resolver, location);
@@ -118,9 +117,10 @@
validatePackagesFile(resolver, location);
});
- httpTest(".packages not recursive",
- {".packages": packagesFile, "subdir": {"script.dart": "main(){}"}},
- (Uri location) async {
+ httpTest(".packages not recursive", {
+ ".packages": packagesFile,
+ "subdir": {"script.dart": "main(){}"}
+ }, (Uri location) async {
Packages resolver;
var subdir = location.resolve("subdir/");
resolver = await findPackages(subdir);
@@ -133,9 +133,7 @@
validatePackagesDir(resolver, subdir);
});
- fileTest("no packages",
- {"script.dart": "main(){}"},
- (Uri location) async {
+ fileTest("no packages", {"script.dart": "main(){}"}, (Uri location) async {
// A file: location with no .packages or packages returns
// Packages.noPackages.
Packages resolver;
@@ -149,9 +147,7 @@
expect(resolver, same(Packages.noPackages));
});
- httpTest("no packages",
- {"script.dart": "main(){}"},
- (Uri location) async {
+ httpTest("no packages", {"script.dart": "main(){}"}, (Uri location) async {
// A non-file: location with no .packages or packages/:
// Assumes a packages dir exists, and resolves relative to that.
Packages resolver;
@@ -178,13 +174,13 @@
Packages resolver;
resolver = await findPackages(location, loader: loader);
validatePackagesFile(resolver, location);
- resolver = await findPackages(location.resolve("script.dart"),
- loader: loader);
+ resolver =
+ await findPackages(location.resolve("script.dart"), loader: loader);
validatePackagesFile(resolver, location);
resolver = await findPackagesFromNonFile(location, loader: loader);
validatePackagesFile(resolver, location);
resolver = await findPackagesFromNonFile(location.resolve("script.dart"),
- loader: loader);
+ loader: loader);
validatePackagesFile(resolver, location);
});
@@ -198,27 +194,26 @@
Packages resolver;
resolver = await findPackages(location, loader: loader);
validatePackagesDir(resolver, location);
- resolver = await findPackages(location.resolve("script.dart"),
- loader: loader);
+ resolver =
+ await findPackages(location.resolve("script.dart"), loader: loader);
validatePackagesDir(resolver, location);
resolver = await findPackagesFromNonFile(location, loader: loader);
validatePackagesDir(resolver, location);
resolver = await findPackagesFromNonFile(location.resolve("script.dart"),
- loader:loader);
+ loader: loader);
validatePackagesDir(resolver, location);
});
- generalTest("loadPackagesFile",
- {".packages": packagesFile},
- (Uri directory) async {
+ generalTest("loadPackagesFile", {".packages": packagesFile},
+ (Uri directory) async {
Uri file = directory.resolve(".packages");
Packages resolver = await loadPackagesFile(file);
validatePackagesFile(resolver, file);
});
- generalTest("loadPackagesFile non-default name",
- {"pheldagriff": packagesFile},
- (Uri directory) async {
+ generalTest(
+ "loadPackagesFile non-default name", {"pheldagriff": packagesFile},
+ (Uri directory) async {
Uri file = directory.resolve("pheldagriff");
Packages resolver = await loadPackagesFile(file);
validatePackagesFile(resolver, file);
@@ -231,26 +226,23 @@
validatePackagesFile(resolver, file);
});
- generalTest("loadPackagesFile not found",
- {},
- (Uri directory) async {
+ generalTest("loadPackagesFile not found", {}, (Uri directory) async {
Uri file = directory.resolve(".packages");
expect(loadPackagesFile(file), throws);
});
- generalTest("loadPackagesFile syntax error",
- {".packages": "syntax error"},
- (Uri directory) async {
+ generalTest("loadPackagesFile syntax error", {".packages": "syntax error"},
+ (Uri directory) async {
Uri file = directory.resolve(".packages");
expect(loadPackagesFile(file), throws);
});
- generalTest("getPackagesDir",
- {"packages": {"foo": {}, "bar": {}, "baz": {}}},
- (Uri directory) async {
+ generalTest("getPackagesDir", {
+ "packages": {"foo": {}, "bar": {}, "baz": {}}
+ }, (Uri directory) async {
Uri packages = directory.resolve("packages/");
Packages resolver = getPackagesDirectory(packages);
- Uri resolved = resolver.resolve(pkg("foo","flip/flop"));
+ Uri resolved = resolver.resolve(pkg("foo", "flip/flop"));
expect(resolved, packages.resolve("foo/flip/flop"));
});
}
@@ -260,9 +252,7 @@
/// Description is a map, each key is a file entry. If the value is a map,
/// it's a sub-dir, otherwise it's a file and the value is the content
/// as a string.
-void fileTest(String name,
- Map description,
- Future fileTest(Uri directory)) {
+void fileTest(String name, Map description, Future fileTest(Uri directory)) {
group("file-test", () {
Directory tempDir = Directory.systemTemp.createTempSync("file-test");
setUp(() {
@@ -285,31 +275,27 @@
var serverSub;
var uri;
setUp(() {
- return HttpServer
- .bind(InternetAddress.LOOPBACK_IP_V4, 0)
- .then((server) {
- uri = new Uri(scheme: "http",
- host: "127.0.0.1",
- port: server.port,
- path: "/");
- serverSub = server.listen((HttpRequest request) {
- // No error handling.
- var path = request.uri.path;
- if (path.startsWith('/')) path = path.substring(1);
- if (path.endsWith('/')) path = path.substring(0, path.length - 1);
- var parts = path.split('/');
- var fileOrDir = description;
- for (int i = 0; i < parts.length; i++) {
- fileOrDir = fileOrDir[parts[i]];
- if (fileOrDir == null) {
- request.response.statusCode = 404;
- request.response.close();
- }
+ return HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) {
+ uri = new Uri(
+ scheme: "http", host: "127.0.0.1", port: server.port, path: "/");
+ serverSub = server.listen((HttpRequest request) {
+ // No error handling.
+ var path = request.uri.path;
+ if (path.startsWith('/')) path = path.substring(1);
+ if (path.endsWith('/')) path = path.substring(0, path.length - 1);
+ var parts = path.split('/');
+ var fileOrDir = description;
+ for (int i = 0; i < parts.length; i++) {
+ fileOrDir = fileOrDir[parts[i]];
+ if (fileOrDir == null) {
+ request.response.statusCode = 404;
+ request.response.close();
}
- request.response.write(fileOrDir);
- request.response.close();
- });
+ }
+ request.response.write(fileOrDir);
+ request.response.close();
});
+ });
});
tearDown(() => serverSub.cancel());
test(name, () => httpTest(uri));
diff --git a/test/parse_test.dart b/test/parse_test.dart
index 8ed5c2e..7a2fce7 100644
--- a/test/parse_test.dart
+++ b/test/parse_test.dart
@@ -73,8 +73,7 @@
test("multiple", () {
var packages = doParse(multiRelativeSample, base);
- expect(
- packages.packages.toList()..sort(), equals(["bar", "foo"]));
+ expect(packages.packages.toList()..sort(), equals(["bar", "foo"]));
expect(packages.resolve(Uri.parse("package:foo/bar/baz.dart")),
equals(base.resolve("../test/").resolve("bar/baz.dart")));
expect(packages.resolve(Uri.parse("package:bar/foo/baz.dart")),
@@ -135,33 +134,32 @@
}
// Valid samples.
-var emptySample = "";
-var commentOnlySample = "# comment only\n";
-var emptyLinesSample = "\n\n\r\n";
-var singleRelativeSample = "foo:../test/\n";
-var singleRelativeSampleNoSlash = "foo:../test\n";
+var emptySample = "";
+var commentOnlySample = "# comment only\n";
+var emptyLinesSample = "\n\n\r\n";
+var singleRelativeSample = "foo:../test/\n";
+var singleRelativeSampleNoSlash = "foo:../test\n";
var singleRelativeSampleNoNewline = "foo:../test/";
-var singleAbsoluteSample = "foo:http://example.com/some/where/\n";
-var singleEmptyPathSample = "foo:\n";
-var singleAbsolutePathSample = "foo:/test/\n";
-var multiRelativeSample = "foo:../test/\nbar:../test2/\n";
+var singleAbsoluteSample = "foo:http://example.com/some/where/\n";
+var singleEmptyPathSample = "foo:\n";
+var singleAbsolutePathSample = "foo:/test/\n";
+var multiRelativeSample = "foo:../test/\nbar:../test2/\n";
// All valid path segment characters in an URI.
-var allValidChars =
- r"!$&'()*+,-.0123456789;="
+var allValidChars = r"!$&'()*+,-.0123456789;="
r"@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~";
var allValidCharsSample = "${allValidChars}:../test/\n";
// Invalid samples.
var invalid = [
- ":baz.dart", // empty.
- "foobar=baz.dart", // no colon (but an equals, which is not the same)
- ".:../test/", // dot segment
- "..:../test/", // dot-dot segment
- "...:../test/", // dot-dot-dot segment
- "foo/bar:../test/", // slash in name
- "/foo:../test/", // slash at start of name
- "?:../test/", // invalid characters.
- "[:../test/", // invalid characters.
- "x#:../test/", // invalid characters.
+ ":baz.dart", // empty.
+ "foobar=baz.dart", // no colon (but an equals, which is not the same)
+ ".:../test/", // dot segment
+ "..:../test/", // dot-dot segment
+ "...:../test/", // dot-dot-dot segment
+ "foo/bar:../test/", // slash in name
+ "/foo:../test/", // slash at start of name
+ "?:../test/", // invalid characters.
+ "[:../test/", // invalid characters.
+ "x#:../test/", // invalid characters.
];
diff --git a/test/parse_write_test.dart b/test/parse_write_test.dart
index 6a185db..29c2224 100644
--- a/test/parse_write_test.dart
+++ b/test/parse_write_test.dart
@@ -52,12 +52,17 @@
roundTripTest("http directory", {"foo": httpDir});
roundTripTest("other scheme directory", {"foo": otherDir});
roundTripTest("multiple same-type directories",
- {"foo": lowerDir, "bar": higherDir, "baz": parallelDir});
+ {"foo": lowerDir, "bar": higherDir, "baz": parallelDir});
roundTripTest("multiple scheme directories",
- {"foo": fileDir, "bar": httpDir, "baz": otherDir});
- roundTripTest("multiple scheme directories and mutliple same type",
- {"foo": fileDir, "bar": httpDir, "baz": otherDir,
- "qux": lowerDir, "hip": higherDir, "dep": parallelDir});
+ {"foo": fileDir, "bar": httpDir, "baz": otherDir});
+ roundTripTest("multiple scheme directories and mutliple same type", {
+ "foo": fileDir,
+ "bar": httpDir,
+ "baz": otherDir,
+ "qux": lowerDir,
+ "hip": higherDir,
+ "dep": parallelDir
+ });
});
}