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

Side by Side Diff: tests/utils/uri_test.dart

Issue 10989013: Change IllegalArgumentException to ArgumentError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated co19 test expectations. Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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('uriTest'); 5 #library('uriTest');
6 6
7 #import('../../lib/utf/utf.dart'); 7 #import('../../lib/utf/utf.dart');
8 #import('../../lib/uri/uri.dart'); 8 #import('../../lib/uri/uri.dart');
9 9
10 testUri(String uri, bool isAbsolute) { 10 testUri(String uri, bool isAbsolute) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 "https://example.com", 135 "https://example.com",
136 new Uri.fromString("https://example.com/a/b/c").origin); 136 new Uri.fromString("https://example.com/a/b/c").origin);
137 Expect.stringEquals( 137 Expect.stringEquals(
138 "http://example.com:1234", 138 "http://example.com:1234",
139 new Uri.fromString("http://example.com:1234/a/b/c").origin); 139 new Uri.fromString("http://example.com:1234/a/b/c").origin);
140 Expect.stringEquals( 140 Expect.stringEquals(
141 "https://example.com:1234", 141 "https://example.com:1234",
142 new Uri.fromString("https://example.com:1234/a/b/c").origin); 142 new Uri.fromString("https://example.com:1234/a/b/c").origin);
143 Expect.throws( 143 Expect.throws(
144 () => new Uri.fromString("http:").origin, 144 () => new Uri.fromString("http:").origin,
145 (e) { return e is IllegalArgumentException; }, 145 (e) { return e is ArgumentError; },
146 "origin for uri with empty domain should fail"); 146 "origin for uri with empty domain should fail");
147 Expect.throws( 147 Expect.throws(
148 () => const Uri.fromComponents( 148 () => const Uri.fromComponents(
149 scheme: "http", 149 scheme: "http",
150 userInfo: null, 150 userInfo: null,
151 domain: "", 151 domain: "",
152 port: 80, 152 port: 80,
153 path: "/a/b/c", 153 path: "/a/b/c",
154 query: "query", 154 query: "query",
155 fragment: "fragment").origin, 155 fragment: "fragment").origin,
156 (e) { return e is IllegalArgumentException; }, 156 (e) { return e is ArgumentError; },
157 "origin for uri with empty domain should fail"); 157 "origin for uri with empty domain should fail");
158 Expect.throws( 158 Expect.throws(
159 () => const Uri.fromComponents( 159 () => const Uri.fromComponents(
160 scheme: null, 160 scheme: null,
161 userInfo: null, 161 userInfo: null,
162 domain: "", 162 domain: "",
163 port: 80, 163 port: 80,
164 path: "/a/b/c", 164 path: "/a/b/c",
165 query: "query", 165 query: "query",
166 fragment: "fragment").origin, 166 fragment: "fragment").origin,
167 (e) { return e is IllegalArgumentException; }, 167 (e) { return e is ArgumentError; },
168 "origin for uri with empty scheme should fail"); 168 "origin for uri with empty scheme should fail");
169 Expect.throws( 169 Expect.throws(
170 () => const Uri.fromComponents( 170 () => const Uri.fromComponents(
171 scheme: "http", 171 scheme: "http",
172 userInfo: null, 172 userInfo: null,
173 domain: null, 173 domain: null,
174 port: 80, 174 port: 80,
175 path: "/a/b/c", 175 path: "/a/b/c",
176 query: "query", 176 query: "query",
177 fragment: "fragment").origin, 177 fragment: "fragment").origin,
178 (e) { return e is IllegalArgumentException; }, 178 (e) { return e is ArgumentError; },
179 "origin for uri with empty domain should fail"); 179 "origin for uri with empty domain should fail");
180 Expect.throws( 180 Expect.throws(
181 () => new Uri.fromString("http://:80").origin, 181 () => new Uri.fromString("http://:80").origin,
182 (e) { return e is IllegalArgumentException; }, 182 (e) { return e is ArgumentError; },
183 "origin for uri with empty domain should fail"); 183 "origin for uri with empty domain should fail");
184 Expect.throws( 184 Expect.throws(
185 () => new Uri.fromString("file://localhost/test.txt").origin, 185 () => new Uri.fromString("file://localhost/test.txt").origin,
186 (e) { return e is IllegalArgumentException; }, 186 (e) { return e is ArgumentError; },
187 "origin for non-http/https uri should fail"); 187 "origin for non-http/https uri should fail");
188 188
189 // URI encode tests 189 // URI encode tests
190 // Note: dart2js won't handle '\ud800\udc00' and frog 190 // Note: dart2js won't handle '\ud800\udc00' and frog
191 // won't handle '\u{10000}'. So we cons this up synthetically... 191 // won't handle '\u{10000}'. So we cons this up synthetically...
192 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]); 192 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]);
193 193
194 testEncodeDecode("\uFFFE", "%EF%BF%BE"); 194 testEncodeDecode("\uFFFE", "%EF%BF%BE");
195 testEncodeDecode("\uFFFF", "%EF%BF%BF"); 195 testEncodeDecode("\uFFFF", "%EF%BF%BF");
196 testEncodeDecode("\uFFFE", "%EF%BF%BE"); 196 testEncodeDecode("\uFFFE", "%EF%BF%BE");
197 testEncodeDecode("\uFFFF", "%EF%BF%BF"); 197 testEncodeDecode("\uFFFF", "%EF%BF%BF");
198 testEncodeDecode("\x7f", "%7F"); 198 testEncodeDecode("\x7f", "%7F");
199 testEncodeDecode("\x80", "%C2%80"); 199 testEncodeDecode("\x80", "%C2%80");
200 testEncodeDecode("\u0800", "%E0%A0%80"); 200 testEncodeDecode("\u0800", "%E0%A0%80");
201 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=+\$"); 201 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=+\$");
202 testEncodeDecode(s, "%F0%90%80%80"); 202 testEncodeDecode(s, "%F0%90%80%80");
203 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); 203 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE");
204 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); 204 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF");
205 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); 205 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE");
206 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); 206 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF");
207 testEncodeDecodeComponent("\x7f", "%7F"); 207 testEncodeDecodeComponent("\x7f", "%7F");
208 testEncodeDecodeComponent("\x80", "%C2%80"); 208 testEncodeDecodeComponent("\x80", "%C2%80");
209 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); 209 testEncodeDecodeComponent("\u0800", "%E0%A0%80");
210 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); 210 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24");
211 testEncodeDecodeComponent(s, "%F0%90%80%80"); 211 testEncodeDecodeComponent(s, "%F0%90%80%80");
212 } 212 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698