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

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

Issue 13896034: Add the ability to change the working directory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed tests Created 7 years, 8 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/directory_impl.dart ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/directory_chdir_test.dart
diff --git a/tests/standalone/io/directory_chdir_test.dart b/tests/standalone/io/directory_chdir_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0805e3a58ad4aecd813bce93c6b11efc069b67a5
--- /dev/null
+++ b/tests/standalone/io/directory_chdir_test.dart
@@ -0,0 +1,50 @@
+// 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.
+//
+// Directory listing test.
+
+
+import "dart:io";
+import "dart:isolate";
+
+import "package:expect/expect.dart";
+
+testChangeDirectory() {
+ var port = new ReceivePort();
+ new Directory("").createTemp().then((temp) {
+ var initialCurrent = Directory.current;
+ Directory.current = temp;
+ var newCurrent = Directory.current;
+ new File("111").createSync();
+ var dir = new Directory(newCurrent.path + Platform.pathSeparator + "222");
+ dir.createSync();
+ Directory.current = dir;
+ new File("333").createSync();
+ Expect.isTrue(new File("333").existsSync());
+ Expect.isTrue(new File("../111").existsSync());
+ Directory.current = "..";
+ Expect.isTrue(new File("111").existsSync());
+ Expect.isTrue(new File("222/333").existsSync());
+ Directory.current = initialCurrent;
+ temp.deleteSync(recursive: true);
+ port.close();
+ });
+}
+
+
+testChangeDirectoryIllegalArguments() {
+ Expect.throws(() => Directory.current = 1, (e) => e is ArgumentError);
+ Expect.throws(() => Directory.current = 111111111111111111111111111111111111,
+ (e) => e is ArgumentError);
+ Expect.throws(() => Directory.current = true, (e) => e is ArgumentError);
+ Expect.throws(() => Directory.current = [], (e) => e is ArgumentError);
+ Expect.throws(() => Directory.current = new File("xxx"),
+ (e) => e is ArgumentError);
+}
+
+
+main() {
+ testChangeDirectory();
+ testChangeDirectoryIllegalArguments();
+}
« no previous file with comments | « sdk/lib/io/directory_impl.dart ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698