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

Side by Side Diff: test/codegen/expect/corelib/uri_file_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 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 dart_library.library('corelib/uri_file_test', null, /* Imports */[
2 'dart_sdk',
3 'expect'
4 ], function load__uri_file_test(exports, dart_sdk, expect) {
5 'use strict';
6 const core = dart_sdk.core;
7 const _interceptors = dart_sdk._interceptors;
8 const dart = dart_sdk.dart;
9 const dartx = dart_sdk.dartx;
10 const expect$ = expect.expect;
11 const uri_file_test = Object.create(null);
12 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr ray$(core.String)))();
13 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr ray$(core.Object)))();
14 let ListOfObject = () => (ListOfObject = dart.constFn(core.List$(core.Object)) )();
15 let JSArrayOfListOfObject = () => (JSArrayOfListOfObject = dart.constFn(_inter ceptors.JSArray$(ListOfObject())))();
16 let ListOfString = () => (ListOfString = dart.constFn(core.List$(core.String)) )();
17 let JSArrayOfListOfString = () => (JSArrayOfListOfString = dart.constFn(_inter ceptors.JSArray$(ListOfString())))();
18 let VoidToString = () => (VoidToString = dart.constFn(dart.definiteFunctionTyp e(core.String, [])))();
19 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT ype(core.bool, [dart.dynamic])))();
20 let StringAnddynamicAndboolTovoid = () => (StringAnddynamicAndboolTovoid = dar t.constFn(dart.definiteFunctionType(dart.void, [core.String, dart.dynamic, core. bool])))();
21 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
22 let VoidToUri = () => (VoidToUri = dart.constFn(dart.definiteFunctionType(core .Uri, [])))();
23 let StringAndStringAndStringTodynamic = () => (StringAndStringAndStringTodynam ic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.String, core.Str ing, core.String])))();
24 let StringAndStringAndString__Todynamic = () => (StringAndStringAndString__Tod ynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.String, core .String, core.String, core.bool])))();
25 let String__Todynamic = () => (String__Todynamic = dart.constFn(dart.definiteF unctionType(dart.dynamic, [core.String], {windowsOk: core.bool})))();
26 uri_file_test.testFileUri = function() {
27 let unsupported = new core.UnsupportedError("");
28 let tests = JSArrayOfListOfObject().of([JSArrayOfString().of(["", "", ""]), JSArrayOfString().of(["relative", "relative", "relative"]), JSArrayOfString().of (["relative/", "relative/", "relative\\"]), JSArrayOfString().of(["a%20b", "a b" , "a b"]), JSArrayOfString().of(["a%20b/", "a b/", "a b\\"]), JSArrayOfString(). of(["a/b", "a/b", "a\\b"]), JSArrayOfString().of(["a/b/", "a/b/", "a\\b\\"]), JS ArrayOfString().of(["a%20b/c%20d", "a b/c d", "a b\\c d"]), JSArrayOfString().of (["a%20b/c%20d/", "a b/c d/", "a b\\c d\\"]), JSArrayOfString().of(["file:///abs olute", "/absolute", "\\absolute"]), JSArrayOfString().of(["file:///absolute", " /absolute", "\\absolute"]), JSArrayOfString().of(["file:///a/b", "/a/b", "\\a\\b "]), JSArrayOfString().of(["file:///a/b", "/a/b", "\\a\\b"]), JSArrayOfObject(). of(["file://server/a/b", unsupported, "\\\\server\\a\\b"]), JSArrayOfObject().of (["file://server/a/b/", unsupported, "\\\\server\\a\\b\\"]), JSArrayOfString().o f(["file:///C:/", "/C:/", "C:\\"]), JSArrayOfString().of(["file:///C:/a/b", "/C: /a/b", "C:\\a\\b"]), JSArrayOfString().of(["file:///C:/a/b/", "/C:/a/b/", "C:\\a \\b\\"]), JSArrayOfObject().of(["http:/a/b", unsupported, unsupported]), JSArray OfObject().of(["https:/a/b", unsupported, unsupported]), JSArrayOfObject().of([" urn:a:b", unsupported, unsupported])]);
29 function check(s, filePath, windows) {
30 let uri = core.Uri.parse(s);
31 if (core.Error.is(filePath)) {
32 if (core.UnsupportedError.is(filePath)) {
33 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: windows}) , VoidToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
34 } else {
35 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: windows}) , VoidToString()));
36 }
37 } else {
38 expect$.Expect.equals(filePath, uri.toFilePath({windows: windows}));
39 expect$.Expect.equals(s, core.Uri.file(core.String._check(filePath), {wi ndows: windows}).toString());
40 }
41 }
42 dart.fn(check, StringAnddynamicAndboolTovoid());
43 for (let test of tests) {
44 check(core.String._check(test[dartx.get](0)), test[dartx.get](1), false);
45 check(core.String._check(test[dartx.get](0)), test[dartx.get](2), true);
46 }
47 let uri = null;
48 uri = core.Uri.parse("file:a");
49 expect$.Expect.equals("/a", uri.toFilePath({windows: false}));
50 expect$.Expect.equals("\\a", uri.toFilePath({windows: true}));
51 uri = core.Uri.parse("file:a/");
52 expect$.Expect.equals("/a/", uri.toFilePath({windows: false}));
53 expect$.Expect.equals("\\a\\", uri.toFilePath({windows: true}));
54 };
55 dart.fn(uri_file_test.testFileUri, VoidTodynamic());
56 uri_file_test.testFileUriWindowsSlash = function() {
57 let tests = JSArrayOfListOfString().of([JSArrayOfString().of(["", "", ""]), JSArrayOfString().of(["relative", "relative", "relative"]), JSArrayOfString().of (["relative/", "relative/", "relative\\"]), JSArrayOfString().of(["a%20b", "a b" , "a b"]), JSArrayOfString().of(["a%20b/", "a b/", "a b\\"]), JSArrayOfString(). of(["a/b", "a/b", "a\\b"]), JSArrayOfString().of(["a/b/", "a/b/", "a\\b\\"]), JS ArrayOfString().of(["a%20b/c%20d", "a b/c d", "a b\\c d"]), JSArrayOfString().of (["a%20b/c%20d/", "a b/c d/", "a b\\c d\\"]), JSArrayOfString().of(["file:///abs olute", "/absolute", "\\absolute"]), JSArrayOfString().of(["file:///absolute", " /absolute", "\\absolute"]), JSArrayOfString().of(["file:///a/b", "/a/b", "\\a\\b "]), JSArrayOfString().of(["file:///a/b", "/a/b", "\\a\\b"]), JSArrayOfString(). of(["file://server/a/b", "//server/a/b", "\\\\server\\a\\b"]), JSArrayOfString() .of(["file://server/a/b/", "//server/a/b/", "\\\\server\\a\\b\\"]), JSArrayOfStr ing().of(["file:///C:/", "C:/", "C:\\"]), JSArrayOfString().of(["file:///C:/a/b" , "C:/a/b", "C:\\a\\b"]), JSArrayOfString().of(["file:///C:/a/b/", "C:/a/b/", "C :\\a\\b\\"])]);
58 for (let test of tests) {
59 let uri = core.Uri.file(test[dartx.get](1), {windows: true});
60 expect$.Expect.equals(test[dartx.get](0), uri.toString());
61 expect$.Expect.equals(test[dartx.get](2), uri.toFilePath({windows: true})) ;
62 let couldBeDir = dart.test(uri.path[dartx.isEmpty]) || dart.test(uri.path[ dartx.endsWith]('\\'));
63 let dirUri = core.Uri.directory(test[dartx.get](1), {windows: true});
64 expect$.Expect.isTrue(dart.test(dirUri.path[dartx.isEmpty]) || dart.test(d irUri.path[dartx.endsWith]('/')));
65 if (couldBeDir) {
66 expect$.Expect.equals(uri, dirUri);
67 }
68 }
69 };
70 dart.fn(uri_file_test.testFileUriWindowsSlash, VoidTodynamic());
71 uri_file_test.testFileUriWindowsWin32Namespace = function() {
72 let tests = JSArrayOfListOfString().of([JSArrayOfString().of(["\\\\?\\C:\\", "file:///C:/", "C:\\"]), JSArrayOfString().of(["\\\\?\\C:\\", "file:///C:/", "C :\\"]), JSArrayOfString().of(["\\\\?\\UNC\\server\\share\\file", "file://server/ share/file", "\\\\server\\share\\file"])]);
73 for (let test of tests) {
74 let uri = core.Uri.file(test[dartx.get](0), {windows: true});
75 expect$.Expect.equals(test[dartx.get](1), uri.toString());
76 expect$.Expect.equals(test[dartx.get](2), uri.toFilePath({windows: true})) ;
77 }
78 expect$.Expect.throws(dart.fn(() => core.Uri.file("\\\\?\\file", {windows: t rue}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
79 expect$.Expect.throws(dart.fn(() => core.Uri.file("\\\\?\\UNX\\server\\share \\file", {windows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
80 expect$.Expect.throws(dart.fn(() => core.Uri.directory("\\\\?\\file", {windo ws: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool() ));
81 expect$.Expect.throws(dart.fn(() => core.Uri.directory("\\\\?\\UNX\\server\\ share\\file", {windows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is (e), dynamicTobool()));
82 };
83 dart.fn(uri_file_test.testFileUriWindowsWin32Namespace, VoidTodynamic());
84 uri_file_test.testFileUriDriveLetter = function() {
85 function check(s, nonWindows, windows) {
86 let uri = null;
87 uri = core.Uri.parse(s);
88 expect$.Expect.equals(nonWindows, uri.toFilePath({windows: false}));
89 if (windows != null) {
90 expect$.Expect.equals(windows, uri.toFilePath({windows: true}));
91 } else {
92 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: true}), Voi dToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
93 }
94 }
95 dart.fn(check, StringAndStringAndStringTodynamic());
96 check("file:///C:", "/C:", "C:\\");
97 check("file:///C:/", "/C:/", "C:\\");
98 check("file:///C:a", "/C:a", null);
99 check("file:///C:a/", "/C:a/", null);
100 expect$.Expect.throws(dart.fn(() => core.Uri.file("C:", {windows: true}), Vo idToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
101 expect$.Expect.throws(dart.fn(() => core.Uri.file("C:a", {windows: true}), V oidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
102 expect$.Expect.throws(dart.fn(() => core.Uri.file("C:a\b", {windows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
103 expect$.Expect.throws(dart.fn(() => core.Uri.directory("C:", {windows: true} ), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
104 expect$.Expect.throws(dart.fn(() => core.Uri.directory("C:a", {windows: true }), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
105 expect$.Expect.throws(dart.fn(() => core.Uri.directory("C:a\b", {windows: tr ue}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
106 };
107 dart.fn(uri_file_test.testFileUriDriveLetter, VoidTodynamic());
108 uri_file_test.testFileUriResolve = function() {
109 let tests = JSArrayOfListOfString().of([JSArrayOfString().of(["file:///a", " /a", "", "\\a", ""]), JSArrayOfString().of(["file:///a/", "/a/", "", "\\a\\", "" ]), JSArrayOfString().of(["file:///b", "/a", "b", "\\a", "b"]), JSArrayOfString( ).of(["file:///b/", "/a", "b/", "\\a", "b\\"]), JSArrayOfString().of(["file:///a /b", "/a/", "b", "\\a\\", "b"]), JSArrayOfString().of(["file:///a/b/", "/a/", "b /", "\\a\\", "b\\"]), JSArrayOfString().of(["file:///a/c/d", "/a/b", "c/d", "\\a \\b", "c\\d"]), JSArrayOfString().of(["file:///a/c/d/", "/a/b", "c/d/", "\\a\\b" , "c\\d\\"]), JSArrayOfString().of(["file:///a/b/c/d", "/a/b/", "c/d", "\\a\\b\\ ", "c\\d"]), JSArrayOfString().of(["file:///a/b/c/d/", "/a/b/", "c/d/", "\\a\\b\ \", "c\\d\\"])]);
110 function check(s, absolute, relative, windows) {
111 let absoluteUri = core.Uri.file(absolute, {windows: windows});
112 let relativeUri = core.Uri.file(relative, {windows: windows});
113 let relativeString = dart.test(windows) ? relative[dartx.replaceAll]("\\", "/") : relative;
114 expect$.Expect.equals(s, dart.toString(absoluteUri.resolve(relativeString) ));
115 expect$.Expect.equals(s, dart.toString(absoluteUri.resolveUri(relativeUri) ));
116 }
117 dart.fn(check, StringAndStringAndString__Todynamic());
118 for (let test of tests) {
119 check(test[dartx.get](0), test[dartx.get](1), test[dartx.get](2), false);
120 check(test[dartx.get](0), test[dartx.get](1), test[dartx.get](2), true);
121 check(test[dartx.get](0), test[dartx.get](1), test[dartx.get](4), true);
122 check(test[dartx.get](0), test[dartx.get](3), test[dartx.get](2), true);
123 check(test[dartx.get](0), test[dartx.get](3), test[dartx.get](4), true);
124 }
125 };
126 dart.fn(uri_file_test.testFileUriResolve, VoidTodynamic());
127 uri_file_test.testFileUriIllegalCharacters = function() {
128 let uri = core.Uri.parse("file:///a%2Fb");
129 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: false}), VoidTo String()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
130 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: true}), VoidToS tring()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
131 let illegalWindowsPaths = JSArrayOfString().of(["a<b", "a>b", "a:b", "a\"b", "a|b", "a?b", "a*b", "\\\\?\\c:\\a/b"]);
132 for (let test of illegalWindowsPaths) {
133 expect$.Expect.throws(dart.fn(() => core.Uri.file(test, {windows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
134 expect$.Expect.throws(dart.fn(() => core.Uri.file(dart.str`\\${test}`, {wi ndows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicToboo l()));
135 expect$.Expect.throws(dart.fn(() => core.Uri.directory(test, {windows: tru e}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
136 expect$.Expect.throws(dart.fn(() => core.Uri.directory(dart.str`\\${test}` , {windows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamic Tobool()));
137 let uri = core.Uri.file(test, {windows: false});
138 let absoluteUri = core.Uri.file(dart.str`/${test}`, {windows: false});
139 let dirUri = core.Uri.directory(test, {windows: false});
140 let dirAbsoluteUri = core.Uri.directory(dart.str`/${test}`, {windows: fals e});
141 expect$.Expect.throws(dart.fn(() => core.Uri.file(test, {windows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
142 expect$.Expect.throws(dart.fn(() => core.Uri.file(dart.str`\\${test}`, {wi ndows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicToboo l()));
143 expect$.Expect.throws(dart.fn(() => core.Uri.directory(test, {windows: tru e}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
144 expect$.Expect.throws(dart.fn(() => core.Uri.directory(dart.str`\\${test}` , {windows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamic Tobool()));
145 expect$.Expect.equals(test, uri.toFilePath({windows: false}));
146 expect$.Expect.equals(dart.str`/${test}`, absoluteUri.toFilePath({windows: false}));
147 expect$.Expect.equals(dart.str`${test}/`, dirUri.toFilePath({windows: fals e}));
148 expect$.Expect.equals(dart.str`/${test}/`, dirAbsoluteUri.toFilePath({wind ows: false}));
149 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: true}), VoidT oString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
150 expect$.Expect.throws(dart.fn(() => absoluteUri.toFilePath({windows: true} ), VoidToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
151 expect$.Expect.throws(dart.fn(() => dirUri.toFilePath({windows: true}), Vo idToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
152 expect$.Expect.throws(dart.fn(() => dirAbsoluteUri.toFilePath({windows: tr ue}), VoidToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool() ));
153 }
154 illegalWindowsPaths = JSArrayOfString().of(["a\\b", "a\\b\\"]);
155 for (let test of illegalWindowsPaths) {
156 let uri = core.Uri.file(test, {windows: false});
157 let absoluteUri = core.Uri.file(dart.str`/${test}`, {windows: false});
158 let dirUri = core.Uri.directory(test, {windows: false});
159 let dirAbsoluteUri = core.Uri.directory(dart.str`/${test}`, {windows: fals e});
160 core.Uri.file(test, {windows: true});
161 core.Uri.file(dart.str`\\${test}`, {windows: true});
162 expect$.Expect.equals(test, uri.toFilePath({windows: false}));
163 expect$.Expect.equals(dart.str`/${test}`, absoluteUri.toFilePath({windows: false}));
164 expect$.Expect.equals(dart.str`${test}/`, dirUri.toFilePath({windows: fals e}));
165 expect$.Expect.equals(dart.str`/${test}/`, dirAbsoluteUri.toFilePath({wind ows: false}));
166 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: true}), VoidT oString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
167 expect$.Expect.throws(dart.fn(() => absoluteUri.toFilePath({windows: true} ), VoidToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
168 expect$.Expect.throws(dart.fn(() => dirUri.toFilePath({windows: true}), Vo idToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
169 expect$.Expect.throws(dart.fn(() => dirAbsoluteUri.toFilePath({windows: tr ue}), VoidToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool() ));
170 }
171 };
172 dart.fn(uri_file_test.testFileUriIllegalCharacters, VoidTodynamic());
173 uri_file_test.testFileUriIllegalDriveLetter = function() {
174 expect$.Expect.throws(dart.fn(() => core.Uri.file("1:\\", {windows: true}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
175 expect$.Expect.throws(dart.fn(() => core.Uri.directory("1:\\", {windows: tru e}), VoidToUri()), dart.fn(e => core.ArgumentError.is(e), dynamicTobool()));
176 let uri = core.Uri.file("1:\\", {windows: false});
177 let dirUri = core.Uri.directory("1:\\", {windows: false});
178 expect$.Expect.equals("1:\\", uri.toFilePath({windows: false}));
179 expect$.Expect.equals("1:\\/", dirUri.toFilePath({windows: false}));
180 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: true}), VoidToS tring()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
181 expect$.Expect.throws(dart.fn(() => dirUri.toFilePath({windows: true}), Void ToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
182 };
183 dart.fn(uri_file_test.testFileUriIllegalDriveLetter, VoidTodynamic());
184 uri_file_test.testAdditionalComponents = function() {
185 function check(s, opts) {
186 let windowsOk = opts && 'windowsOk' in opts ? opts.windowsOk : false;
187 let uri = core.Uri.parse(s);
188 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: false}), Void ToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
189 if (dart.test(windowsOk)) {
190 expect$.Expect.isTrue(typeof uri.toFilePath({windows: true}) == 'string' );
191 } else {
192 expect$.Expect.throws(dart.fn(() => uri.toFilePath({windows: true}), Voi dToString()), dart.fn(e => core.UnsupportedError.is(e), dynamicTobool()));
193 }
194 }
195 dart.fn(check, String__Todynamic());
196 check("file:///path?query");
197 check("file:///path#fragment");
198 check("file:///path?query#fragment");
199 check("file://host/path", {windowsOk: true});
200 check("file://user:password@host/path", {windowsOk: true});
201 };
202 dart.fn(uri_file_test.testAdditionalComponents, VoidTodynamic());
203 uri_file_test.main = function() {
204 uri_file_test.testFileUri();
205 uri_file_test.testFileUriWindowsSlash();
206 uri_file_test.testFileUriDriveLetter();
207 uri_file_test.testFileUriWindowsWin32Namespace();
208 uri_file_test.testFileUriResolve();
209 uri_file_test.testFileUriIllegalCharacters();
210 uri_file_test.testFileUriIllegalDriveLetter();
211 uri_file_test.testAdditionalComponents();
212 };
213 dart.fn(uri_file_test.main, VoidTodynamic());
214 // Exports:
215 exports.uri_file_test = uri_file_test;
216 });
OLDNEW
« no previous file with comments | « test/codegen/expect/corelib/uri_base_test.js ('k') | test/codegen/expect/corelib/uri_http_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698