Index: dart/tests/compiler/dart2js/uri_extras_test.dart |
diff --git a/dart/tests/compiler/dart2js/uri_extras_test.dart b/dart/tests/compiler/dart2js/uri_extras_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..651865bf827a145ef02dd2c3e7562b27e7a7ee3c |
--- /dev/null |
+++ b/dart/tests/compiler/dart2js/uri_extras_test.dart |
@@ -0,0 +1,70 @@ |
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+#import('dart:uri'); |
+ |
+#import('../../../lib/compiler/implementation/util/uri_extras.dart'); |
+ |
+ |
+void testRelativize() { |
+ void c(String expected, String base, String path, bool isWindows) { |
+ if (isWindows === null) { |
+ c(expected, base, path, true); |
+ c(expected, base, path, false); |
+ return; |
+ } |
+ String r; |
+ |
+ r = relativize(new Uri.fromString('file:$base'), |
+ new Uri.fromString('file:$path'), |
+ isWindows); |
+ Expect.stringEquals(expected, r); |
+ |
+ r = relativize(new Uri.fromString('FILE:$base'), |
+ new Uri.fromString('FILE:$path'), |
+ isWindows); |
+ Expect.stringEquals(expected, r); |
+ |
+ r = relativize(new Uri.fromString('file:$base'), |
+ new Uri.fromString('FILE:$path'), |
+ isWindows); |
+ Expect.stringEquals(expected, r); |
+ |
+ r = relativize(new Uri.fromString('FILE:$base'), |
+ new Uri.fromString('file:$path'), |
+ isWindows); |
+ Expect.stringEquals(expected, r); |
+ } |
+ c('bar', '/', '/bar', null); |
+ c('/bar', '/foo', '/bar', null); |
+ c('/bar', '/foo/', '/bar', null); |
+ |
+ c('bar', '///c:/', '///c:/bar', true); |
+ c('/c:/bar', '///c:/foo', '///c:/bar', true); |
+ c('/c:/bar', '///c:/foo/', '///c:/bar', true); |
+ |
+ c('BAR', '///c:/', '///c:/BAR', true); |
+ c('/c:/BAR', '///c:/foo', '///c:/BAR', true); |
+ c('/c:/BAR', '///c:/foo/', '///c:/BAR', true); |
+ |
+ c('../lib/compiler/implementation/dart2js.dart', |
+ '///C:/Users/person/dart_checkout_for_stuff/dart/ReleaseIA32/dart.exe', |
+ '///c:/Users/person/dart_checkout_for_stuff/dart/lib/compiler/' |
+ 'implementation/dart2js.dart', |
+ true); |
+ |
+ c('/Users/person/file.dart', '/users/person/', '/Users/person/file.dart', |
+ false); |
+ |
+ c('file.dart', '/Users/person/', '/Users/person/file.dart', null); |
+ |
+ c('../person/file.dart', '/Users/other/', '/Users/person/file.dart', false); |
+ |
+ c('/Users/person/file.dart', '/Users/other/', '/Users/person/file.dart', |
+ true); |
+} |
+ |
+void main() { |
+ testRelativize(); |
+} |