| OLD | NEW | 
|---|
| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; | 
| 6 | 6 | 
| 7 testFileUri() { | 7 testFileUri() { | 
| 8   final unsupported = new UnsupportedError(""); | 8   final unsupported = new UnsupportedError(""); | 
| 9 | 9 | 
| 10   var tests = [ | 10   var tests = [ | 
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 217     Expect.throws(() => new Uri.directory(test, windows: true), | 217     Expect.throws(() => new Uri.directory(test, windows: true), | 
| 218                   (e) => e is ArgumentError); | 218                   (e) => e is ArgumentError); | 
| 219     Expect.throws(() => new Uri.directory("\\$test", windows: true), | 219     Expect.throws(() => new Uri.directory("\\$test", windows: true), | 
| 220                   (e) => e is ArgumentError); | 220                   (e) => e is ArgumentError); | 
| 221 | 221 | 
| 222     // It is possible to create non-Windows URIs, but not Windows URIs. | 222     // It is possible to create non-Windows URIs, but not Windows URIs. | 
| 223     Uri uri = new Uri.file(test, windows: false); | 223     Uri uri = new Uri.file(test, windows: false); | 
| 224     Uri absoluteUri = new Uri.file("/$test", windows: false); | 224     Uri absoluteUri = new Uri.file("/$test", windows: false); | 
| 225     Uri dirUri = new Uri.directory(test, windows: false); | 225     Uri dirUri = new Uri.directory(test, windows: false); | 
| 226     Uri dirAbsoluteUri = new Uri.directory("/$test", windows: false); | 226     Uri dirAbsoluteUri = new Uri.directory("/$test", windows: false); | 
| 227     Expect.throws(() => new Uri.file(test, windows: true)); | 227     Expect.throws(() => new Uri.file(test, windows: true), | 
| 228     Expect.throws(() => new Uri.file("\\$test", windows: true)); | 228                   (e) => e is ArgumentError); | 
| 229     Expect.throws(() => new Uri.direcory(test, windows: true)); | 229     Expect.throws(() => new Uri.file("\\$test", windows: true), | 
| 230     Expect.throws(() => new Uri.directory("\\$test", windows: true)); | 230                   (e) => e is ArgumentError); | 
|  | 231     Expect.throws(() => new Uri.directory(test, windows: true), | 
|  | 232                   (e) => e is ArgumentError); | 
|  | 233     Expect.throws(() => new Uri.directory("\\$test", windows: true), | 
|  | 234                   (e) => e is ArgumentError); | 
| 231 | 235 | 
| 232     // It is possible to extract non-Windows file path, but not | 236     // It is possible to extract non-Windows file path, but not | 
| 233     // Windows file path. | 237     // Windows file path. | 
| 234     Expect.equals(test, uri.toFilePath(windows: false)); | 238     Expect.equals(test, uri.toFilePath(windows: false)); | 
| 235     Expect.equals("/$test", absoluteUri.toFilePath(windows: false)); | 239     Expect.equals("/$test", absoluteUri.toFilePath(windows: false)); | 
| 236     Expect.equals("$test/", dirUri.toFilePath(windows: false)); | 240     Expect.equals("$test/", dirUri.toFilePath(windows: false)); | 
| 237     Expect.equals("/$test/", dirAbsoluteUri.toFilePath(windows: false)); | 241     Expect.equals("/$test/", dirAbsoluteUri.toFilePath(windows: false)); | 
| 238     Expect.throws(() => uri.toFilePath(windows: true)); | 242     Expect.throws(() => uri.toFilePath(windows: true), | 
| 239     Expect.throws(() => absoluteUri.toFilePath(windows: true)); | 243                   (e) => e is UnsupportedError); | 
| 240     Expect.throws(() => dirUri.toFilePath(windows: true)); | 244     Expect.throws(() => absoluteUri.toFilePath(windows: true), | 
| 241     Expect.throws(() => dirAbsoluteUri.toFilePath(windows: true)); | 245                   (e) => e is UnsupportedError); | 
|  | 246     Expect.throws(() => dirUri.toFilePath(windows: true), | 
|  | 247                   (e) => e is UnsupportedError); | 
|  | 248     Expect.throws(() => dirAbsoluteUri.toFilePath(windows: true), | 
|  | 249                   (e) => e is UnsupportedError); | 
| 242   } | 250   } | 
| 243 | 251 | 
| 244   // Backslash | 252   // Backslash | 
| 245   illegalWindowsPaths = ["a\\b", "a\\b\\"]; | 253   illegalWindowsPaths = ["a\\b", "a\\b\\"]; | 
| 246   for (var test in illegalWindowsPaths) { | 254   for (var test in illegalWindowsPaths) { | 
| 247     // It is possible to create both non-Windows URIs, and Windows URIs. | 255     // It is possible to create both non-Windows URIs, and Windows URIs. | 
| 248     Uri uri = new Uri.file(test, windows: false); | 256     Uri uri = new Uri.file(test, windows: false); | 
| 249     Uri absoluteUri = new Uri.file("/$test", windows: false); | 257     Uri absoluteUri = new Uri.file("/$test", windows: false); | 
| 250     Uri dirUri = new Uri.directory(test, windows: false); | 258     Uri dirUri = new Uri.directory(test, windows: false); | 
| 251     Uri dirAbsoluteUri = new Uri.directory("/$test", windows: false); | 259     Uri dirAbsoluteUri = new Uri.directory("/$test", windows: false); | 
| 252     new Uri.file(test, windows: true); | 260     new Uri.file(test, windows: true); | 
| 253     new Uri.file("\\$test", windows: true); | 261     new Uri.file("\\$test", windows: true); | 
| 254 | 262 | 
| 255     // It is possible to extract non-Windows file path, but not | 263     // It is possible to extract non-Windows file path, but not | 
| 256     // Windows file path from the non-Windows URI (it has a backslash | 264     // Windows file path from the non-Windows URI (it has a backslash | 
| 257     // in a path segment). | 265     // in a path segment). | 
| 258     Expect.equals(test, uri.toFilePath(windows: false)); | 266     Expect.equals(test, uri.toFilePath(windows: false)); | 
| 259     Expect.equals("/$test", absoluteUri.toFilePath(windows: false)); | 267     Expect.equals("/$test", absoluteUri.toFilePath(windows: false)); | 
| 260     Expect.equals("$test/", dirUri.toFilePath(windows: false)); | 268     Expect.equals("$test/", dirUri.toFilePath(windows: false)); | 
| 261     Expect.equals("/$test/", dirAbsoluteUri.toFilePath(windows: false)); | 269     Expect.equals("/$test/", dirAbsoluteUri.toFilePath(windows: false)); | 
| 262     Expect.throws(() => uri.toFilePath(windows: true), | 270     Expect.throws(() => uri.toFilePath(windows: true), | 
| 263                   (e) => e is UnsupportedError); | 271                   (e) => e is UnsupportedError); | 
| 264     Expect.throws(() => absoluteUri.toFilePath(windows: true)); | 272     Expect.throws(() => absoluteUri.toFilePath(windows: true), | 
|  | 273                   (e) => e is UnsupportedError); | 
| 265     Expect.throws(() => dirUri.toFilePath(windows: true), | 274     Expect.throws(() => dirUri.toFilePath(windows: true), | 
| 266                   (e) => e is UnsupportedError); | 275                   (e) => e is UnsupportedError); | 
| 267     Expect.throws(() => dirAbsoluteUri.toFilePath(windows: true)); | 276     Expect.throws(() => dirAbsoluteUri.toFilePath(windows: true), | 
|  | 277                   (e) => e is UnsupportedError); | 
| 268   } | 278   } | 
| 269 } | 279 } | 
| 270 | 280 | 
| 271 testFileUriIllegalDriveLetter() { | 281 testFileUriIllegalDriveLetter() { | 
| 272   Expect.throws(() => new Uri.file("1:\\", windows: true), | 282   Expect.throws(() => new Uri.file("1:\\", windows: true), | 
| 273                 (e) => e is ArgumentError); | 283                 (e) => e is ArgumentError); | 
| 274   Expect.throws(() => new Uri.directory("1:\\", windows: true), | 284   Expect.throws(() => new Uri.directory("1:\\", windows: true), | 
| 275                 (e) => e is ArgumentError); | 285                 (e) => e is ArgumentError); | 
| 276   Uri uri = new Uri.file("1:\\", windows: false); | 286   Uri uri = new Uri.file("1:\\", windows: false); | 
| 277   Uri dirUri = new Uri.directory("1:\\", windows: false); | 287   Uri dirUri = new Uri.directory("1:\\", windows: false); | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 306 main() { | 316 main() { | 
| 307   testFileUri(); | 317   testFileUri(); | 
| 308   testFileUriWindowsSlash(); | 318   testFileUriWindowsSlash(); | 
| 309   testFileUriDriveLetter(); | 319   testFileUriDriveLetter(); | 
| 310   testFileUriWindowsWin32Namespace(); | 320   testFileUriWindowsWin32Namespace(); | 
| 311   testFileUriResolve(); | 321   testFileUriResolve(); | 
| 312   testFileUriIllegalCharacters(); | 322   testFileUriIllegalCharacters(); | 
| 313   testFileUriIllegalDriveLetter(); | 323   testFileUriIllegalDriveLetter(); | 
| 314   testAdditionalComponents(); | 324   testAdditionalComponents(); | 
| 315 } | 325 } | 
| OLD | NEW | 
|---|