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

Side by Side Diff: tests/corelib_strong/uri_path_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:collection"; 5 import "dart:collection";
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 void testInvalidArguments() { 9 void testInvalidArguments() {}
10 }
11 10
12 void testPath() { 11 void testPath() {
13 void test(s, uri) { 12 void test(s, uri) {
14 Expect.equals(s, uri.toString()); 13 Expect.equals(s, uri.toString());
15 Expect.equals(uri, Uri.parse(s)); 14 Expect.equals(uri, Uri.parse(s));
16 } 15 }
17 16
18 test("http:", new Uri(scheme: "http")); 17 test("http:", new Uri(scheme: "http"));
19 test("http://host/xxx", new Uri(scheme: "http", host: "host", path: "xxx")); 18 test("http://host/xxx", new Uri(scheme: "http", host: "host", path: "xxx"));
20 test("http://host/xxx", new Uri(scheme: "http", host: "host", path: "/xxx")); 19 test("http://host/xxx", new Uri(scheme: "http", host: "host", path: "/xxx"));
21 test("http://host/xxx", 20 test("http://host/xxx",
22 new Uri(scheme: "http", host: "host", pathSegments: ["xxx"])); 21 new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]));
23 test("http://host/xxx/yyy", 22 test("http://host/xxx/yyy",
24 new Uri(scheme: "http", host: "host", path: "xxx/yyy")); 23 new Uri(scheme: "http", host: "host", path: "xxx/yyy"));
25 test("http://host/xxx/yyy", 24 test("http://host/xxx/yyy",
26 new Uri(scheme: "http", host: "host", path: "/xxx/yyy")); 25 new Uri(scheme: "http", host: "host", path: "/xxx/yyy"));
27 test("http://host/xxx/yyy", 26 test("http://host/xxx/yyy",
28 new Uri(scheme: "http", host: "host", pathSegments: ["xxx", "yyy"])); 27 new Uri(scheme: "http", host: "host", pathSegments: ["xxx", "yyy"]));
29 28
30 test("urn:", new Uri(scheme: "urn")); 29 test("urn:", new Uri(scheme: "urn"));
31 test("urn:xxx", new Uri(scheme: "urn", path: "xxx")); 30 test("urn:xxx", new Uri(scheme: "urn", path: "xxx"));
32 test("urn:xxx:yyy", new Uri(scheme: "urn", path: "xxx:yyy")); 31 test("urn:xxx:yyy", new Uri(scheme: "urn", path: "xxx:yyy"));
33 32
34 Expect.equals(3, new Uri(path: "xxx/yyy/zzz").pathSegments.length); 33 Expect.equals(3, new Uri(path: "xxx/yyy/zzz").pathSegments.length);
35 Expect.equals(3, new Uri(path: "/xxx/yyy/zzz").pathSegments.length); 34 Expect.equals(3, new Uri(path: "/xxx/yyy/zzz").pathSegments.length);
36 Expect.equals(3, Uri.parse("http://host/xxx/yyy/zzz").pathSegments.length); 35 Expect.equals(3, Uri.parse("http://host/xxx/yyy/zzz").pathSegments.length);
37 Expect.equals(3, Uri.parse("file:///xxx/yyy/zzz").pathSegments.length); 36 Expect.equals(3, Uri.parse("file:///xxx/yyy/zzz").pathSegments.length);
38 } 37 }
(...skipping 21 matching lines...) Expand all
60 test("%C3%B8/%C3%A5", ["ø", "å"]); 59 test("%C3%B8/%C3%A5", ["ø", "å"]);
61 test("%C8%A4/%E5%B9%B3%E4%BB%AE%E5%90%8D", ["Ȥ", "平仮名"]); 60 test("%C8%A4/%E5%B9%B3%E4%BB%AE%E5%90%8D", ["Ȥ", "平仮名"]);
62 test("A/b", ["A", "b"]); 61 test("A/b", ["A", "b"]);
63 test("A/%25", ["A", "%"]); 62 test("A/%25", ["A", "%"]);
64 test("%2F/a%2Fb", ["/", "a/b"]); 63 test("%2F/a%2Fb", ["/", "a/b"]);
65 test("name;v=1.1", ["name;v=1.1"]); 64 test("name;v=1.1", ["name;v=1.1"]);
66 test("name,v=1.1", ["name,v=1.1"]); 65 test("name,v=1.1", ["name,v=1.1"]);
67 test("name;v=1.1/name,v=1.1", ["name;v=1.1", "name,v=1.1"]); 66 test("name;v=1.1/name,v=1.1", ["name;v=1.1", "name,v=1.1"]);
68 67
69 var unreserved = "-._~0123456789" 68 var unreserved = "-._~0123456789"
70 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 69 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
71 "abcdefghijklmnopqrstuvwxyz"; 70 "abcdefghijklmnopqrstuvwxyz";
72 var subDelimiters = r"!$&'()*+,;="; 71 var subDelimiters = r"!$&'()*+,;=";
73 var additionalPathChars = ":@"; 72 var additionalPathChars = ":@";
74 var pchar = unreserved + subDelimiters + additionalPathChars; 73 var pchar = unreserved + subDelimiters + additionalPathChars;
75 74
76 var encoded = new StringBuffer(); 75 var encoded = new StringBuffer();
77 var unencoded = new StringBuffer(); 76 var unencoded = new StringBuffer();
78 for (int i = 32; i < 128; i++) { 77 for (int i = 32; i < 128; i++) {
79 if (pchar.indexOf(new String.fromCharCode(i)) != -1) { 78 if (pchar.indexOf(new String.fromCharCode(i)) != -1) {
80 encoded.writeCharCode(i); 79 encoded.writeCharCode(i);
81 } else { 80 } else {
(...skipping 10 matching lines...) Expand all
92 Uri uri; 91 Uri uri;
93 List pathSegments = ["xxx", "yyy", "zzz"]; 92 List pathSegments = ["xxx", "yyy", "zzz"];
94 93
95 uri = new Uri(pathSegments: pathSegments); 94 uri = new Uri(pathSegments: pathSegments);
96 Expect.equals(3, uri.pathSegments.length); 95 Expect.equals(3, uri.pathSegments.length);
97 uri = new Uri(pathSegments: pathSegments.where((_) => true)); 96 uri = new Uri(pathSegments: pathSegments.where((_) => true));
98 Expect.equals(3, uri.pathSegments.length); 97 Expect.equals(3, uri.pathSegments.length);
99 uri = new Uri(pathSegments: new DoubleLinkedQueue.from(pathSegments)); 98 uri = new Uri(pathSegments: new DoubleLinkedQueue.from(pathSegments));
100 Expect.equals(3, uri.pathSegments.length); 99 Expect.equals(3, uri.pathSegments.length);
101 100
102 uri = new Uri(scheme: "http", 101 uri = new Uri(scheme: "http", host: "host", pathSegments: pathSegments);
103 host: "host",
104 pathSegments: pathSegments);
105 Expect.equals(3, uri.pathSegments.length); 102 Expect.equals(3, uri.pathSegments.length);
106 uri = new Uri(scheme: "http", 103 uri = new Uri(
107 host: "host", 104 scheme: "http",
108 pathSegments: pathSegments.where((_) => true)); 105 host: "host",
106 pathSegments: pathSegments.where((_) => true));
109 Expect.equals(3, uri.pathSegments.length); 107 Expect.equals(3, uri.pathSegments.length);
110 uri = new Uri(scheme: "http", 108 uri = new Uri(
111 host: "host", 109 scheme: "http",
112 pathSegments: new DoubleLinkedQueue.from(pathSegments)); 110 host: "host",
111 pathSegments: new DoubleLinkedQueue.from(pathSegments));
113 Expect.equals(3, uri.pathSegments.length); 112 Expect.equals(3, uri.pathSegments.length);
114 113
115 uri = new Uri(scheme: "file", 114 uri = new Uri(scheme: "file", pathSegments: pathSegments);
116 pathSegments: pathSegments);
117 Expect.equals(3, uri.pathSegments.length); 115 Expect.equals(3, uri.pathSegments.length);
118 uri = new Uri(scheme: "file", 116 uri = new Uri(scheme: "file", pathSegments: pathSegments.where((_) => true));
119 pathSegments: pathSegments.where((_) => true));
120 Expect.equals(3, uri.pathSegments.length); 117 Expect.equals(3, uri.pathSegments.length);
121 uri = new Uri(scheme: "file", 118 uri = new Uri(
122 pathSegments: new DoubleLinkedQueue.from(pathSegments)); 119 scheme: "file", pathSegments: new DoubleLinkedQueue.from(pathSegments));
123 Expect.equals(3, uri.pathSegments.length); 120 Expect.equals(3, uri.pathSegments.length);
124 } 121 }
125 122
126 void testPathCompare() { 123 void testPathCompare() {
127 void test(Uri uri1, Uri uri2) { 124 void test(Uri uri1, Uri uri2) {
128 Expect.equals(uri1, uri2); 125 Expect.equals(uri1, uri2);
129 Expect.equals(uri2, uri1); 126 Expect.equals(uri2, uri1);
130 } 127 }
131 128
132 test(new Uri(scheme: "http", host: "host", path: "xxx"), 129 test(new Uri(scheme: "http", host: "host", path: "xxx"),
133 new Uri(scheme: "http", host: "host", path: "/xxx")); 130 new Uri(scheme: "http", host: "host", path: "/xxx"));
134 test(new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]), 131 test(new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]),
135 new Uri(scheme: "http", host: "host", path: "/xxx")); 132 new Uri(scheme: "http", host: "host", path: "/xxx"));
136 test(new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]), 133 test(new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]),
137 new Uri(scheme: "http", host: "host", path: "xxx")); 134 new Uri(scheme: "http", host: "host", path: "xxx"));
138 test(new Uri(scheme: "file", path: "xxx"), 135 test(new Uri(scheme: "file", path: "xxx"),
139 new Uri(scheme: "file", path: "/xxx")); 136 new Uri(scheme: "file", path: "/xxx"));
140 test(new Uri(scheme: "file", pathSegments: ["xxx"]), 137 test(new Uri(scheme: "file", pathSegments: ["xxx"]),
141 new Uri(scheme: "file", path: "/xxx")); 138 new Uri(scheme: "file", path: "/xxx"));
142 test(new Uri(scheme: "file", pathSegments: ["xxx"]), 139 test(new Uri(scheme: "file", pathSegments: ["xxx"]),
143 new Uri(scheme: "file", path: "xxx")); 140 new Uri(scheme: "file", path: "xxx"));
144 } 141 }
145 142
146 testPathSegmentsUnmodifiableList() { 143 testPathSegmentsUnmodifiableList() {
147 void test(list) { 144 void test(list) {
148 bool isUnsupported(e) => e is UnsupportedError; 145 bool isUnsupported(e) => e is UnsupportedError;
149 146
150 Expect.equals("a", list[0]); 147 Expect.equals("a", list[0]);
151 Expect.throws(() => list[0] = "c", isUnsupported); 148 Expect.throws(() => list[0] = "c", isUnsupported);
152 Expect.equals(2, list.length); 149 Expect.equals(2, list.length);
153 Expect.throws(() => list.length = 1, isUnsupported); 150 Expect.throws(() => list.length = 1, isUnsupported);
(...skipping 28 matching lines...) Expand all
182 test(new Uri(pathSegments: ["a", "b"]).pathSegments); 179 test(new Uri(pathSegments: ["a", "b"]).pathSegments);
183 } 180 }
184 181
185 main() { 182 main() {
186 testInvalidArguments(); 183 testInvalidArguments();
187 testPath(); 184 testPath();
188 testPathSegments(); 185 testPathSegments();
189 testPathCompare(); 186 testPathCompare();
190 testPathSegmentsUnmodifiableList(); 187 testPathSegmentsUnmodifiableList();
191 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698