diff --git a/lib/src/backends/local/local_directory.dart b/lib/src/backends/local/local_directory.dart index fc3aa360d90a4..1b7ecbdc044a8 100644 --- a/lib/src/backends/local/local_directory.dart +++ b/lib/src/backends/local/local_directory.dart @@ -8,4 +8,7 @@ class _LocalDirectory 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 99a0eeaff1341..3d91072f20da8 100644 --- a/lib/src/backends/local/local_file.dart +++ b/lib/src/backends/local/local_file.dart @@ -7,4 +7,7 @@ part of file.src.backends.local; class _LocalFile extends _LocalFileSystemEntity 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 a65b07153c570..7de0278406f4a 100644 --- a/lib/src/backends/local/local_link.dart +++ b/lib/src/backends/local/local_link.dart @@ -7,4 +7,7 @@ part of file.src.backends.local; class _LocalLink extends _LocalFileSystemEntity 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 ba8d572b95748..5fc0af6e85548 100644 --- a/lib/src/backends/memory/memory_directory.dart +++ b/lib/src/backends/memory/memory_directory.dart @@ -137,6 +137,9 @@ class _MemoryDirectory extends _MemoryFileSystemEntity implements Directory { @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 a2e84992a584b..05e6d09e013bb 100644 --- a/lib/src/backends/memory/memory_file.dart +++ b/lib/src/backends/memory/memory_file.dart @@ -240,6 +240,9 @@ class _MemoryFile extends _MemoryFileSystemEntity implements File { 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 efbec6b34e682..2d636466daa39 100644 --- a/lib/src/backends/memory/memory_link.dart +++ b/lib/src/backends/memory/memory_link.dart @@ -92,4 +92,7 @@ class _MemoryLink extends _MemoryFileSystemEntity implements Link { @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 72705f8011354..0e893ab86f7a7 100644 --- a/test/local_test.dart +++ b/test/local_test.dart @@ -67,5 +67,19 @@ void main() { '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 5cafac3ce8dc5..b9682317ca54b 100644 --- a/test/memory_test.dart +++ b/test/memory_test.dart @@ -9,11 +9,31 @@ import 'common_tests.dart'; void main() { group('MemoryFileSystem', () { + MemoryFileSystem fs; + + setUp(() { + fs = new MemoryFileSystem(); + }); + runCommonTests( - () => new MemoryFileSystem(), + () => fs, skip: [ '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'"); + }); + }); }); }