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

Unified Diff: tests/standalone/io/file_absolute_path_test.dart

Issue 23468027: Add FileSystemEntity.absolutePath and .isAbsolute properties. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« sdk/lib/io/file_system_entity.dart ('K') | « sdk/lib/io/file_system_entity.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/file_absolute_path_test.dart
diff --git a/tests/standalone/io/file_absolute_path_test.dart b/tests/standalone/io/file_absolute_path_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d362c1c28db174ea337784ef348d94b5ceb4e251
--- /dev/null
+++ b/tests/standalone/io/file_absolute_path_test.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2013, 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.
+//
+// Dart test program for testing FileSystemEntity.absolutePath
+
+import "package:expect/expect.dart";
+import 'dart:io';
+
+main() {
+ if (Platform.isWindows) {
+ testWindows();
+ try {
+ Directory.current = 'C:\\';
+ } catch (e) {
+ return;
+ }
+ testWindows();
+ } else {
+ testPosix();
+ Directory.current = '.';
+ testPosix();
+ Directory.current = '/';
+ testPosix();
+
+ }
+}
+
+testWindows() {
+ String current = Directory.current.path;
+ for (String relative in ['abd', '..', '.', 'efg/hij', 'abc/']) {
+ if (current.endsWith('\\')) {
+ Expect.equals(new File(relative).absolutePath, '$current$relative');
+ } else {
+ Expect.equals(new File(relative).absolutePath, '$current\\$relative');
+ }
+ Expect.isTrue(new File(new File(relative).absolutePath).isAbsolute);
+ }
+ for (String absolute in ['c:/abd', 'D:\\rf', '\\\\a_share\\folder',
+ '\\\\?\\c:\\prefixed\path\\']) {
+ Expect.isTrue(new File(absolute).absolutePath == absolute);
+ Expect.isTrue(new File(absolute).isAbsolute);
+ }
+}
+
+testPosix() {
+ String current = Directory.current.path;
+ print(Directory.current.path);
+ for (String relative in ['abd', '..', '.', 'efg/hij', 'abc/']) {
+ if (current.endsWith('/')) {
+ Expect.equals(new File(relative).absolutePath, '$current$relative');
+ } else {
+ Expect.equals(new File(relative).absolutePath, '$current/$relative');
+ }
+ Expect.isTrue(new File(new File(relative).absolutePath).isAbsolute);
+ Expect.equals(new Directory(relative).absolutePath,
+ new Link(relative).absolutePath);
+ }
+ for (String absolute in ['/abd', '/', '/./..\\', '/efg/hij', '/abc/']) {
+ Expect.equals(new File(absolute).absolutePath, absolute);
+ Expect.isTrue(new File(absolute).isAbsolute);
+ }
+}
« sdk/lib/io/file_system_entity.dart ('K') | « sdk/lib/io/file_system_entity.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698