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

Side by Side Diff: tests/standalone/io/directory_test.dart

Issue 52363002: dart:io | Add 'recursive' flag to File.create and Link.create. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove recursive call to create(), simplifying control flow. Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Directory listing test. 5 // Directory listing test.
6 6
7 import "dart:async"; 7 import "dart:async";
8 import "dart:io"; 8 import "dart:io";
9 9
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 Expect.isTrue(error is FileSystemException); 587 Expect.isTrue(error is FileSystemException);
588 temp.delete(recursive: true).then((_) { 588 temp.delete(recursive: true).then((_) {
589 asyncEnd(); 589 asyncEnd();
590 }); 590 });
591 }); 591 });
592 }); 592 });
593 }); 593 });
594 } 594 }
595 595
596 596
597 testCreateRecursiveSync() {
Anders Johnsen 2013/10/30 12:23:56 These tests could be copied directory to the new f
598 var temp = Directory.systemTemp.createTempSync('directory_test');
599 var d = new Directory('${temp.path}/a/b/c');
600 d.createSync(recursive: true);
601 Expect.isTrue(new Directory('${temp.path}/a').existsSync());
602 Expect.isTrue(new Directory('${temp.path}/a/b').existsSync());
603 Expect.isTrue(new Directory('${temp.path}/a/b/c').existsSync());
604 temp.deleteSync(recursive: true);
605 }
606
607
608 testCreateRecursive() {
609 asyncStart();
610 Directory.systemTemp.createTemp('dart_directory').then((temp) {
611 var d = new Directory('${temp.path}/a/b/c');
612 d.create(recursive: true).then((_) {
613 Expect.isTrue(new Directory('${temp.path}/a').existsSync());
614 Expect.isTrue(new Directory('${temp.path}/a/b').existsSync());
615 Expect.isTrue(new Directory('${temp.path}/a/b/c').existsSync());
616 temp.deleteSync(recursive: true);
617 asyncEnd();
618 });
619 });
620 }
621
622
623 testRename() { 597 testRename() {
624 var temp1 = Directory.systemTemp.createTempSync('directory_test'); 598 var temp1 = Directory.systemTemp.createTempSync('directory_test');
625 var temp2 = Directory.systemTemp.createTempSync('directory_test'); 599 var temp2 = Directory.systemTemp.createTempSync('directory_test');
626 var temp3 = temp1.renameSync(temp2.path); 600 var temp3 = temp1.renameSync(temp2.path);
627 Expect.isFalse(temp1.existsSync()); 601 Expect.isFalse(temp1.existsSync());
628 Expect.isTrue(temp2.existsSync()); 602 Expect.isTrue(temp2.existsSync());
629 Expect.equals(temp3.path, temp2.path); 603 Expect.equals(temp3.path, temp2.path);
630 604
631 temp2.rename(temp1.path).then((temp4) { 605 temp2.rename(temp1.path).then((temp4) {
632 Expect.isFalse(temp3.existsSync()); 606 Expect.isFalse(temp3.existsSync());
633 Expect.isFalse(temp2.existsSync()); 607 Expect.isFalse(temp2.existsSync());
634 Expect.isTrue(temp1.existsSync()); 608 Expect.isTrue(temp1.existsSync());
635 Expect.isTrue(temp4.existsSync()); 609 Expect.isTrue(temp4.existsSync());
636 Expect.equals(temp1.path, temp4.path); 610 Expect.equals(temp1.path, temp4.path);
637 temp1.deleteSync(recursive: true); 611 temp1.deleteSync(recursive: true);
638 }); 612 });
639 } 613 }
640 614
641 main() { 615 main() {
642 DirectoryTest.testMain(); 616 DirectoryTest.testMain();
643 NestedTempDirectoryTest.testMain(); 617 NestedTempDirectoryTest.testMain();
644 testCreateTempErrorSync(); 618 testCreateTempErrorSync();
645 testCreateTempError(); 619 testCreateTempError();
646 testCreateExistingSync(); 620 testCreateExistingSync();
647 testCreateExisting(); 621 testCreateExisting();
648 testCreateDirExistingFileSync(); 622 testCreateDirExistingFileSync();
649 testCreateDirExistingFile(); 623 testCreateDirExistingFile();
650 testCreateRecursive();
651 testCreateRecursiveSync();
652 testRename(); 624 testRename();
653 } 625 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698