OLD | NEW |
(Empty) | |
| 1 dart_library.library('corelib/uri_http_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__uri_http_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const uri_http_test = Object.create(null); |
| 11 let UriAndStringTovoid = () => (UriAndStringTovoid = dart.constFn(dart.definit
eFunctionType(dart.void, [core.Uri, core.String])))(); |
| 12 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 13 uri_http_test.testHttpUri = function() { |
| 14 function check(uri, expected) { |
| 15 expect$.Expect.equals(expected, dart.toString(uri)); |
| 16 } |
| 17 dart.fn(check, UriAndStringTovoid()); |
| 18 check(core.Uri.http("", ""), "http:"); |
| 19 check(core.Uri.http("@:", ""), "http://"); |
| 20 check(core.Uri.http("@:8080", ""), "http://:8080"); |
| 21 check(core.Uri.http("@host:", ""), "http://host"); |
| 22 check(core.Uri.http("@host:", ""), "http://host"); |
| 23 check(core.Uri.http("xxx:yyy@host:8080", ""), "http://xxx:yyy@host:8080"); |
| 24 check(core.Uri.http("host", "a"), "http://host/a"); |
| 25 check(core.Uri.http("host", "/a"), "http://host/a"); |
| 26 check(core.Uri.http("host", "a/"), "http://host/a/"); |
| 27 check(core.Uri.http("host", "/a/"), "http://host/a/"); |
| 28 check(core.Uri.http("host", "a/b"), "http://host/a/b"); |
| 29 check(core.Uri.http("host", "/a/b"), "http://host/a/b"); |
| 30 check(core.Uri.http("host", "a/b/"), "http://host/a/b/"); |
| 31 check(core.Uri.http("host", "/a/b/"), "http://host/a/b/"); |
| 32 check(core.Uri.http("host", "a b"), "http://host/a%20b"); |
| 33 check(core.Uri.http("host", "/a b"), "http://host/a%20b"); |
| 34 check(core.Uri.http("host", "/a b/"), "http://host/a%20b/"); |
| 35 check(core.Uri.http("host", "/a%2F"), "http://host/a%252F"); |
| 36 check(core.Uri.http("host", "/a%2F/"), "http://host/a%252F/"); |
| 37 check(core.Uri.http("host", "/a/b", dart.map({c: "d"})), "http://host/a/b?c=
d"); |
| 38 check(core.Uri.http("host", "/a/b", dart.map({"c=": "&d"})), "http://host/a/
b?c%3D=%26d"); |
| 39 check(core.Uri.http("[::]", "a"), "http://[::]/a"); |
| 40 check(core.Uri.http("[::127.0.0.1]", "a"), "http://[::127.0.0.1]/a"); |
| 41 }; |
| 42 dart.fn(uri_http_test.testHttpUri, VoidTodynamic()); |
| 43 uri_http_test.testHttpsUri = function() { |
| 44 function check(uri, expected) { |
| 45 expect$.Expect.equals(expected, dart.toString(uri)); |
| 46 } |
| 47 dart.fn(check, UriAndStringTovoid()); |
| 48 check(core.Uri.https("", ""), "https:"); |
| 49 check(core.Uri.https("@:", ""), "https://"); |
| 50 check(core.Uri.https("@:8080", ""), "https://:8080"); |
| 51 check(core.Uri.https("@host:", ""), "https://host"); |
| 52 check(core.Uri.https("@host:", ""), "https://host"); |
| 53 check(core.Uri.https("xxx:yyy@host:8080", ""), "https://xxx:yyy@host:8080"); |
| 54 check(core.Uri.https("host", "a"), "https://host/a"); |
| 55 check(core.Uri.https("host", "/a"), "https://host/a"); |
| 56 check(core.Uri.https("host", "a/"), "https://host/a/"); |
| 57 check(core.Uri.https("host", "/a/"), "https://host/a/"); |
| 58 check(core.Uri.https("host", "a/b"), "https://host/a/b"); |
| 59 check(core.Uri.https("host", "/a/b"), "https://host/a/b"); |
| 60 check(core.Uri.https("host", "a/b/"), "https://host/a/b/"); |
| 61 check(core.Uri.https("host", "/a/b/"), "https://host/a/b/"); |
| 62 check(core.Uri.https("host", "a b"), "https://host/a%20b"); |
| 63 check(core.Uri.https("host", "/a b"), "https://host/a%20b"); |
| 64 check(core.Uri.https("host", "/a b/"), "https://host/a%20b/"); |
| 65 check(core.Uri.https("host", "/a%2F"), "https://host/a%252F"); |
| 66 check(core.Uri.https("host", "/a%2F/"), "https://host/a%252F/"); |
| 67 check(core.Uri.https("host", "/a/b", dart.map({c: "d"})), "https://host/a/b?
c=d"); |
| 68 check(core.Uri.https("host", "/a/b", dart.map({"c=": "&d"})), "https://host/
a/b?c%3D=%26d"); |
| 69 check(core.Uri.https("[::]", "a"), "https://[::]/a"); |
| 70 check(core.Uri.https("[::127.0.0.1]", "a"), "https://[::127.0.0.1]/a"); |
| 71 }; |
| 72 dart.fn(uri_http_test.testHttpsUri, VoidTodynamic()); |
| 73 uri_http_test.testResolveHttpScheme = function() { |
| 74 let s = "//myserver:1234/path/some/thing"; |
| 75 let uri = core.Uri.parse(s); |
| 76 let http = core.Uri.new({scheme: "http"}); |
| 77 let https = core.Uri.new({scheme: "https"}); |
| 78 expect$.Expect.equals(dart.str`http:${s}`, dart.toString(http.resolveUri(uri
))); |
| 79 expect$.Expect.equals(dart.str`https:${s}`, dart.toString(https.resolveUri(u
ri))); |
| 80 }; |
| 81 dart.fn(uri_http_test.testResolveHttpScheme, VoidTodynamic()); |
| 82 uri_http_test.main = function() { |
| 83 uri_http_test.testHttpUri(); |
| 84 uri_http_test.testHttpsUri(); |
| 85 uri_http_test.testResolveHttpScheme(); |
| 86 }; |
| 87 dart.fn(uri_http_test.main, VoidTodynamic()); |
| 88 // Exports: |
| 89 exports.uri_http_test = uri_http_test; |
| 90 }); |
OLD | NEW |