OLD | NEW |
(Empty) | |
| 1 dart_library.library('corelib/uri_normalize_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__uri_normalize_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_normalize_test = Object.create(null); |
| 11 let StringAndString__Todynamic = () => (StringAndString__Todynamic = dart.cons
tFn(dart.definiteFunctionType(dart.dynamic, [core.String, core.String], {scheme:
core.String, host: core.String})))(); |
| 12 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 13 uri_normalize_test.testNormalizePath = function() { |
| 14 function test(expected, path, opts) { |
| 15 let scheme = opts && 'scheme' in opts ? opts.scheme : null; |
| 16 let host = opts && 'host' in opts ? opts.host : null; |
| 17 let uri = core.Uri.new({scheme: scheme, host: host, path: path}); |
| 18 expect$.Expect.equals(expected, uri.toString()); |
| 19 if (scheme == null && host == null) { |
| 20 expect$.Expect.equals(expected, uri.path); |
| 21 } |
| 22 } |
| 23 dart.fn(test, StringAndString__Todynamic()); |
| 24 let unreserved = "-._~0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefgh
ijklmnopqrstuvwxyz"; |
| 25 test("A", "%41"); |
| 26 test("AB", "%41%42"); |
| 27 test("%40AB", "%40%41%42"); |
| 28 test("a", "%61"); |
| 29 test("ab", "%61%62"); |
| 30 test("%60ab", "%60%61%62"); |
| 31 test(unreserved, unreserved); |
| 32 let x = new core.StringBuffer(); |
| 33 for (let i = 32; i < 128; i++) { |
| 34 if (unreserved[dartx.indexOf](core.String.fromCharCode(i)) != -1) { |
| 35 x.writeCharCode(i); |
| 36 } else { |
| 37 x.write("%"); |
| 38 x.write(i[dartx.toRadixString](16)); |
| 39 } |
| 40 } |
| 41 expect$.Expect.equals(x.toString()[dartx.toUpperCase](), core.Uri.new({path:
x.toString()}).toString()[dartx.toUpperCase]()); |
| 42 test("/a/b/c/", "/../a/./b/z/../c/d/.."); |
| 43 test("/a/b/c/", "/./a/b/c/"); |
| 44 test("/a/b/c/", "/./../a/b/c/"); |
| 45 test("/a/b/c/", "/./../a/b/c/."); |
| 46 test("/a/b/c/", "/./../a/b/c/z/./.."); |
| 47 test("/", "/a/.."); |
| 48 test("s:a/b/c/", "../a/./b/z/../c/d/..", {scheme: "s"}); |
| 49 test("s:a/b/c/", "./a/b/c/", {scheme: "s"}); |
| 50 test("s:a/b/c/", "./../a/b/c/", {scheme: "s"}); |
| 51 test("s:a/b/c/", "./../a/b/c/.", {scheme: "s"}); |
| 52 test("s:a/b/c/", "./../a/b/c/z/./..", {scheme: "s"}); |
| 53 test("s:/", "/a/..", {scheme: "s"}); |
| 54 test("s:/", "a/..", {scheme: "s"}); |
| 55 test("//h/a/b/c/", "../a/./b/z/../c/d/..", {host: "h"}); |
| 56 test("//h/a/b/c/", "./a/b/c/", {host: "h"}); |
| 57 test("//h/a/b/c/", "./../a/b/c/", {host: "h"}); |
| 58 test("//h/a/b/c/", "./../a/b/c/.", {host: "h"}); |
| 59 test("//h/a/b/c/", "./../a/b/c/z/./..", {host: "h"}); |
| 60 test("//h/", "/a/..", {host: "h"}); |
| 61 test("//h/", "a/..", {host: "h"}); |
| 62 test("../a/b/c/", "../a/./b/z/../c/d/.."); |
| 63 test("a/b/c/", "./a/b/c/"); |
| 64 test("../a/b/c/", "./../a/b/c/"); |
| 65 test("../a/b/c/", "./../a/b/c/."); |
| 66 test("../a/b/c/", "./../a/b/c/z/./.."); |
| 67 test("/", "/a/.."); |
| 68 test("./", "a/.."); |
| 69 }; |
| 70 dart.fn(uri_normalize_test.testNormalizePath, VoidTodynamic()); |
| 71 uri_normalize_test.main = function() { |
| 72 uri_normalize_test.testNormalizePath(); |
| 73 }; |
| 74 dart.fn(uri_normalize_test.main, VoidTodynamic()); |
| 75 // Exports: |
| 76 exports.uri_normalize_test = uri_normalize_test; |
| 77 }); |
OLD | NEW |