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

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

Issue 12691002: dart:io | Add Link class, as sibling to File and Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows errors Created 7 years, 9 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
Index: tests/standalone/io/link_test.dart
diff --git a/tests/standalone/io/link_test.dart b/tests/standalone/io/link_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..afcffb84eaccaf829003a56d1d7eb167ef4b608a
--- /dev/null
+++ b/tests/standalone/io/link_test.dart
@@ -0,0 +1,55 @@
+// 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.
+
+import "dart:io";
+import "dart:isolate";
+
+// Test the dart:io Link class.
+
+testCreateSync() {
+ Path base = new Path(new Directory('').createTempSync().path);
+ String link = base.append('link').toNativePath();
+ String target = base.append('target').toNativePath();
+ new Directory(target).createSync();
+ new Link(link).createSync(target);
+
+ Expect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.typeSync(link));
+ Expect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.typeSync(target));
+ Expect.equals(FileSystemEntityType.LINK,
+ FileSystemEntity.typeSync(link, followLinks: false));
+ Expect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.typeSync(target, followLinks: false));
+ Expect.isTrue(FileSystemEntity.isLinkSync(link));
+ Expect.isFalse(FileSystemEntity.isLinkSync(target));
+ Expect.isTrue(new Directory(link).existsSync());
+ Expect.isTrue(new Directory(target).existsSync());
+ Expect.isTrue(new Link(link).existsSync());
+ Expect.isFalse(new Link(target).existsSync());
+
+ String createdThroughLink =
+ base.append('link/createdThroughLink').toNativePath();
+ String createdDirectly = base.append('target/createdDirectly').toNativePath();
+ new Directory(createdThroughLink).createSync();
+ new Directory(createdDirectly).createSync();
+ Expect.isTrue(new Directory(createdThroughLink).existsSync());
+ Expect.isTrue(new Directory(createdDirectly).existsSync());
+ Expect.isTrue(new Directory.fromPath(base.append('link/createdDirectly'))
+ .existsSync());
+ Expect.isTrue(new Directory.fromPath(base.append('target/createdThroughLink'))
+ .existsSync());
+ Expect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.typeSync(createdThroughLink,
+ followLinks: false));
+ Expect.equals(FileSystemEntityType.DIRECTORY,
+ FileSystemEntity.typeSync(createdDirectly, followLinks: false));
+
+ new Directory.fromPath(base).deleteSync(recursive: true);
+}
+
+
+main() {
+ testCreateSync();
+}
« no previous file with comments | « tests/standalone/io/file_system_links_test.dart ('k') | tests/standalone/io/windows_file_system_links_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698