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

Side by Side Diff: test/codegen/corelib/uri_parse_test.dart

Issue 1945153002: Add corelib tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: error_test and range_error_test now pass Created 4 years, 7 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7
8 void testUriCombi() {
9 var schemes = ["", "file", "ws", "ftp"];
10 var fragments = ["", "#", "#f", "#fragment", "#l:?/"];
11 var queries = ["", "?", "?q", "?query", "?q:/"];
12 var paths = ["/", "/x", "/x/y", "/x/y/", "/x:y", "x", "x/y", "x/y/"];
13 var userInfos = ["", "x", "xxx", "x:4", "xxx:444", "x:4:x"];
14 var hosts = ["", "h", "hhh", "h:4", "hhh:444", "[::1.2.3.4]"];
15
16 void check(uriString, scheme, fragment, query, path, user, host) {
17 for (var uri in [Uri.parse(uriString),
18 Uri.parse(">\u{10000}>$uriString<\u{10000}<",
19 4, uriString.length + 4),
20 Uri.parse("http://example.com/$uriString#?:/[]\"",
21 19, uriString.length + 19),
22 Uri.parse(uriString * 3,
23 uriString.length, uriString.length * 2)]) {
24 String name = "$uriString -> $uri";
25 Expect.equals(scheme, uri.scheme, name);
26 var uriFragment = uri.fragment;
27 if (fragment.startsWith('#')) uriFragment = "#$uriFragment";
28 Expect.equals(fragment, uriFragment, name);
29 var uriQuery = uri.query;
30 if (query.startsWith('?')) uriQuery = "?$uriQuery";
31 Expect.equals(query, uriQuery, name);
32 Expect.equals(path, uri.path, name);
33 Expect.equals(user, uri.userInfo, name);
34 var uriHost = uri.host;
35 if (host.startsWith("[")) uriHost = "[$uriHost]";
36 if (uri.port != 0) uriHost += ":${uri.port}";
37 Expect.equals(host, uriHost, name);
38 }
39 }
40
41 for (var scheme in schemes) {
42 for (var fragment in fragments) {
43 for (var query in queries) {
44 for (var path in paths) {
45 // File scheme URIs always get a leading slash.
46 if (scheme == "file" && !path.startsWith('/')) continue;
47 for (var user in userInfos) {
48 for (var host in hosts) {
49 var auth = host;
50 var s = scheme;
51 if (user.isNotEmpty) auth = "$user@$auth";
52 if (auth.isNotEmpty) auth = "//$auth";
53 if (auth.isNotEmpty && !path.startsWith('/')) continue;
54 check("$scheme${scheme.isEmpty ? "" : ":"}"
55 "$auth$path$query$fragment",
56 scheme,
57 fragment,
58 query,
59 path,
60 user,
61 host);
62 }
63 }
64 }
65 }
66 }
67 }
68 }
69
70 void main() {
71 testUriCombi();
72 }
OLDNEW
« no previous file with comments | « test/codegen/corelib/uri_parameters_all_test.dart ('k') | test/codegen/corelib/uri_path_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698