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

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: Change name to absolute, return type to File, Directory, and Link. 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
« no previous file with comments | « sdk/lib/io/link.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..e2785bf1b3b9b72f8f05b04106f46b7e315e0751
--- /dev/null
+++ b/tests/standalone/io/file_absolute_path_test.dart
@@ -0,0 +1,66 @@
+// 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.absolute
+
+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).absolute.path, '$current$relative');
+ } else {
+ Expect.equals(new File(relative).absolute.path, '$current\\$relative');
+ }
+ Expect.isTrue(new File(relative).absolute.isAbsolute);
+ }
+ for (String absolute in ['c:/abd', 'D:\\rf', '\\\\a_share\\folder',
+ '\\\\?\\c:\\prefixed\path\\']) {
+ Expect.isTrue(new File(absolute).absolute.path == absolute);
+ Expect.isTrue(new File(absolute).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).absolute.path, '$current$relative');
+ } else {
+ Expect.equals(new File(relative).absolute.path, '$current/$relative');
+ }
+ Expect.isTrue(new File(relative).absolute.isAbsolute);
+ Expect.equals(new Directory(relative).absolute.path,
+ new Link(relative).absolute.path);
+ Expect.isTrue(new File(relative).absolute is File);
+ Expect.isTrue(new Directory(relative).absolute is Directory);
+ Expect.isTrue(new Link(relative).absolute is Link);
+ }
+ for (String absolute in ['/abd', '/', '/./..\\', '/efg/hij', '/abc/']) {
+ Expect.equals(new File(absolute).absolute.path, absolute);
+ Expect.isTrue(new File(absolute).absolute.isAbsolute);
+ }
+}
« no previous file with comments | « sdk/lib/io/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698