Better toString() implementations (#68)
Fixes #67
diff --git a/lib/src/backends/local/local_directory.dart b/lib/src/backends/local/local_directory.dart
index fc3aa36..1b7ecbd 100644
--- a/lib/src/backends/local/local_directory.dart
+++ b/lib/src/backends/local/local_directory.dart
@@ -8,4 +8,7 @@
extends _LocalFileSystemEntity<_LocalDirectory, io.Directory>
with ForwardingDirectory {
_LocalDirectory(FileSystem fs, io.Directory delegate) : super(fs, delegate);
+
+ @override
+ String toString() => "LocalDirectory: '$path'";
}
diff --git a/lib/src/backends/local/local_file.dart b/lib/src/backends/local/local_file.dart
index 99a0eea..3d91072 100644
--- a/lib/src/backends/local/local_file.dart
+++ b/lib/src/backends/local/local_file.dart
@@ -7,4 +7,7 @@
class _LocalFile extends _LocalFileSystemEntity<File, io.File>
with ForwardingFile {
_LocalFile(FileSystem fs, io.File delegate) : super(fs, delegate);
+
+ @override
+ String toString() => "LocalFile: '$path'";
}
diff --git a/lib/src/backends/local/local_link.dart b/lib/src/backends/local/local_link.dart
index a65b071..7de0278 100644
--- a/lib/src/backends/local/local_link.dart
+++ b/lib/src/backends/local/local_link.dart
@@ -7,4 +7,7 @@
class _LocalLink extends _LocalFileSystemEntity<Link, io.Link>
with ForwardingLink {
_LocalLink(FileSystem fs, io.Link delegate) : super(fs, delegate);
+
+ @override
+ String toString() => "LocalLink: '$path'";
}
diff --git a/lib/src/backends/memory/memory_directory.dart b/lib/src/backends/memory/memory_directory.dart
index ba8d572..5fc0af6 100644
--- a/lib/src/backends/memory/memory_directory.dart
+++ b/lib/src/backends/memory/memory_directory.dart
@@ -137,6 +137,9 @@
@override
Directory _clone(String path) => new _MemoryDirectory(fileSystem, path);
+
+ @override
+ String toString() => "MemoryDirectory: '$path'";
}
class _PendingListTask {
diff --git a/lib/src/backends/memory/memory_file.dart b/lib/src/backends/memory/memory_file.dart
index a2e8499..05e6d09 100644
--- a/lib/src/backends/memory/memory_file.dart
+++ b/lib/src/backends/memory/memory_file.dart
@@ -240,6 +240,9 @@
node.content.clear();
}
}
+
+ @override
+ String toString() => "MemoryFile: '$path'";
}
/// Implementation of an [io.IOSink] that's backed by a [_FileNode].
diff --git a/lib/src/backends/memory/memory_link.dart b/lib/src/backends/memory/memory_link.dart
index efbec6b..2d63646 100644
--- a/lib/src/backends/memory/memory_link.dart
+++ b/lib/src/backends/memory/memory_link.dart
@@ -92,4 +92,7 @@
@override
Link _clone(String path) => new _MemoryLink(fileSystem, path);
+
+ @override
+ String toString() => "MemoryLink: '$path'";
}
diff --git a/test/local_test.dart b/test/local_test.dart
index 72705f8..0e893ab 100644
--- a/test/local_test.dart
+++ b/test/local_test.dart
@@ -67,5 +67,19 @@
'Link > rename > throwsIfDestinationExistsAsFile',
],
);
+
+ group('toString', () {
+ test('File', () {
+ expect(fs.file('/foo').toString(), "LocalFile: '/foo'");
+ });
+
+ test('Directory', () {
+ expect(fs.directory('/foo').toString(), "LocalDirectory: '/foo'");
+ });
+
+ test('Link', () {
+ expect(fs.link('/foo').toString(), "LocalLink: '/foo'");
+ });
+ });
});
}
diff --git a/test/memory_test.dart b/test/memory_test.dart
index 5cafac3..b968231 100644
--- a/test/memory_test.dart
+++ b/test/memory_test.dart
@@ -9,11 +9,31 @@
void main() {
group('MemoryFileSystem', () {
+ MemoryFileSystem fs;
+
+ setUp(() {
+ fs = new MemoryFileSystem();
+ });
+
runCommonTests(
- () => new MemoryFileSystem(),
+ () => fs,
skip: <String>[
'File > open', // Not yet implemented
],
);
+
+ group('toString', () {
+ test('File', () {
+ expect(fs.file('/foo').toString(), "MemoryFile: '/foo'");
+ });
+
+ test('Directory', () {
+ expect(fs.directory('/foo').toString(), "MemoryDirectory: '/foo'");
+ });
+
+ test('Link', () {
+ expect(fs.link('/foo').toString(), "MemoryLink: '/foo'");
+ });
+ });
});
}