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

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

Issue 12850010: Add FileSystemEntity.identical, to test if two file system objects are the same. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve posix versions 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:io"; 5 import "dart:io";
6 import "dart:isolate"; 6 import "dart:isolate";
7 7
8 // Test the dart:io Link class. 8 // Test the dart:io Link class.
9 9
10 testCreateSync() { 10 testCreateSync() {
(...skipping 30 matching lines...) Expand all
41 Expect.isTrue(new Directory.fromPath(base.append('link/createdDirectly')) 41 Expect.isTrue(new Directory.fromPath(base.append('link/createdDirectly'))
42 .existsSync()); 42 .existsSync());
43 Expect.isTrue(new Directory.fromPath(base.append('target/createdThroughLink')) 43 Expect.isTrue(new Directory.fromPath(base.append('target/createdThroughLink'))
44 .existsSync()); 44 .existsSync());
45 Expect.equals(FileSystemEntityType.DIRECTORY, 45 Expect.equals(FileSystemEntityType.DIRECTORY,
46 FileSystemEntity.typeSync(createdThroughLink, 46 FileSystemEntity.typeSync(createdThroughLink,
47 followLinks: false)); 47 followLinks: false));
48 Expect.equals(FileSystemEntityType.DIRECTORY, 48 Expect.equals(FileSystemEntityType.DIRECTORY,
49 FileSystemEntity.typeSync(createdDirectly, followLinks: false)); 49 FileSystemEntity.typeSync(createdDirectly, followLinks: false));
50 50
51 // Test FileSystemEntity.identical on files, directories, and links,
52 // reached by different paths.
53 Expect.isTrue(FileSystemEntity.identicalSync(createdDirectly,
54 createdDirectly));
55 Expect.isFalse(FileSystemEntity.identicalSync(createdDirectly,
56 createdThroughLink));
57 Expect.isTrue(FileSystemEntity.identicalSync(createdDirectly,
58 base.append('link/createdDirectly').toNativePath()));
59 Expect.isTrue(FileSystemEntity.identicalSync(createdThroughLink,
60 base.append('target/createdThroughLink').toNativePath()));
61
62 Expect.isFalse(FileSystemEntity.identicalSync(target, link));
63 Expect.isTrue(FileSystemEntity.identicalSync(link, link));
64 Expect.isTrue(FileSystemEntity.identicalSync(target, target));
65 Expect.isTrue(FileSystemEntity.identicalSync(target,
66 new Link(link).targetSync()));
67 String absolutePath = new File(".").fullPathSync();
68 Expect.isTrue(FileSystemEntity.identicalSync(".", absolutePath));
69
70 String createdFile = base.append('target/createdFile').toNativePath();
71 new File(createdFile).createSync();
72 Expect.isTrue(FileSystemEntity.identicalSync(createdFile, createdFile));
73 Expect.isFalse(FileSystemEntity.identicalSync(createdFile, createdDirectly));
74 Expect.isTrue(FileSystemEntity.identicalSync(createdFile,
75 base.append('link/createdFile').toNativePath()));
76 Expect.throws(() => FileSystemEntity.identicalSync(createdFile,
77 base.append('link/foo').toNativePath()));
78
51 new Directory.fromPath(base).deleteSync(recursive: true); 79 new Directory.fromPath(base).deleteSync(recursive: true);
52 } 80 }
53 81
54 82
55 main() { 83 main() {
56 testCreateSync(); 84 testCreateSync();
57 } 85 }
OLDNEW
« 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