Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2207)

Unified Diff: dart/tests/utils/uri_test.dart

Issue 10850015: Changed default Uri constructor to Uri.fromComponents(), new default constructor is Uri.fromString(… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/tests/utils/dummy_compiler_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/utils/uri_test.dart
diff --git a/dart/tests/utils/uri_test.dart b/dart/tests/utils/uri_test.dart
index ff03d4a35e19747844392b33c32dec047d68db15..419a36e9e94ac87086567ddc6fd11a85b6422e3e 100644
--- a/dart/tests/utils/uri_test.dart
+++ b/dart/tests/utils/uri_test.dart
@@ -9,7 +9,9 @@
testUri(String uri, bool isAbsolute) {
Expect.equals(isAbsolute, new Uri.fromString(uri).isAbsolute());
+ Expect.equals(isAbsolute, new Uri(uri).isAbsolute());
Expect.stringEquals(uri, new Uri.fromString(uri).toString());
+ Expect.stringEquals(uri, new Uri(uri).toString());
}
testEncodeDecode(String orig, String encoded) {
@@ -26,33 +28,8 @@ testEncodeDecodeComponent(String orig, String encoded) {
Expect.stringEquals(orig, d);
}
-main() {
- testUri("http:", true);
- testUri("file://", true);
- testUri("file", false);
- testUri("http://user@example.com:80/fisk?query=89&hest=silas", true);
- testUri("http://user@example.com:80/fisk?query=89&hest=silas#fragment",
- false);
- Expect.stringEquals("http://user@example.com:80/a/b/c?query#fragment",
- const Uri("http", "user", "example.com", 80, "/a/b/c",
- "query", "fragment").toString());
- Expect.stringEquals("null://null@null/a/b/c/?null#null",
- const Uri(null, null, null, 0, "/a/b/c/",
- null, null).toString());
- Expect.stringEquals("file://", new Uri.fromString("file:").toString());
- Expect.stringEquals("/a/g", removeDotSegments("/a/b/c/./../../g"));
- Expect.stringEquals("mid/6", removeDotSegments("mid/content=5/../6"));
- Expect.stringEquals("a/b/e", removeDotSegments("a/b/c/d/../../e"));
- Expect.stringEquals("a/b/e", removeDotSegments("../a/b/c/d/../../e"));
- Expect.stringEquals("a/b/e", removeDotSegments("./a/b/c/d/../../e"));
- Expect.stringEquals("a/b/e", removeDotSegments("../a/b/./c/d/../../e"));
- Expect.stringEquals("a/b/e", removeDotSegments("./a/b/./c/d/../../e"));
- Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/."));
- Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/./."));
- Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/././."));
-
+testUriPerRFCs(URI base) {
// From RFC 3986.
- Uri base = new Uri.fromString("http://a/b/c/d;p?q");
Expect.stringEquals("g:h", base.resolve("g:h").toString());
Expect.stringEquals("http://a/b/c/g", base.resolve("g").toString());
Expect.stringEquals("http://a/b/c/g", base.resolve("./g").toString());
@@ -105,6 +82,41 @@ main() {
// Additional tests (not from RFC 3986).
Expect.stringEquals("http://a/b/g;p/h;s",
base.resolve("../g;p/h;s").toString());
+}
+
+main() {
+ testUri("http:", true);
+ testUri("file://", true);
+ testUri("file", false);
+ testUri("http://user@example.com:80/fisk?query=89&hest=silas", true);
+ testUri("http://user@example.com:80/fisk?query=89&hest=silas#fragment",
+ false);
+ Expect.stringEquals("http://user@example.com:80/a/b/c?query#fragment",
+ const Uri.fromComponents(
+ "http", "user", "example.com", 80, "/a/b/c",
+ "query", "fragment").toString());
+ Expect.stringEquals("null://null@null/a/b/c/?null#null",
+ const Uri.fromComponents(
+ null, null, null, 0, "/a/b/c/",
+ null, null).toString());
+ Expect.stringEquals("file://", new Uri.fromString("file:").toString());
+ Expect.stringEquals("file://", new Uri("file:").toString());
+ Expect.stringEquals("/a/g", removeDotSegments("/a/b/c/./../../g"));
+ Expect.stringEquals("mid/6", removeDotSegments("mid/content=5/../6"));
+ Expect.stringEquals("a/b/e", removeDotSegments("a/b/c/d/../../e"));
+ Expect.stringEquals("a/b/e", removeDotSegments("../a/b/c/d/../../e"));
+ Expect.stringEquals("a/b/e", removeDotSegments("./a/b/c/d/../../e"));
+ Expect.stringEquals("a/b/e", removeDotSegments("../a/b/./c/d/../../e"));
+ Expect.stringEquals("a/b/e", removeDotSegments("./a/b/./c/d/../../e"));
+ Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/."));
+ Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/./."));
+ Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/././."));
+
+ final urisSample = "http://a/b/c/d;p?q";
+ Uri baseFromString = new Uri.fromString(urisSample);
+ testUriPerRFCs(baseFromString);
+ Uri base = new Uri(urisSample);
+ testUriPerRFCs(base);
// URI encode tests
// Note: dart2js won't handle '\ud800\udc00' and frog
« no previous file with comments | « dart/tests/utils/dummy_compiler_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698