Skip to content

Commit

Permalink
Better toString() implementations (flutter#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
tvolkert authored Jan 23, 2017
1 parent 47f0655 commit 094ea68
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/src/backends/local/local_directory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'";
}
3 changes: 3 additions & 0 deletions lib/src/backends/local/local_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ part of file.src.backends.local;
class _LocalFile extends _LocalFileSystemEntity<File, io.File>
with ForwardingFile {
_LocalFile(FileSystem fs, io.File delegate) : super(fs, delegate);

@override
String toString() => "LocalFile: '$path'";
}
3 changes: 3 additions & 0 deletions lib/src/backends/local/local_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ part of file.src.backends.local;
class _LocalLink extends _LocalFileSystemEntity<Link, io.Link>
with ForwardingLink {
_LocalLink(FileSystem fs, io.Link delegate) : super(fs, delegate);

@override
String toString() => "LocalLink: '$path'";
}
3 changes: 3 additions & 0 deletions lib/src/backends/memory/memory_directory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/backends/memory/memory_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
3 changes: 3 additions & 0 deletions lib/src/backends/memory/memory_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,7 @@ class _MemoryLink extends _MemoryFileSystemEntity implements Link {

@override
Link _clone(String path) => new _MemoryLink(fileSystem, path);

@override
String toString() => "MemoryLink: '$path'";
}
14 changes: 14 additions & 0 deletions test/local_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'");
});
});
});
}
22 changes: 21 additions & 1 deletion test/memory_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,31 @@ import 'common_tests.dart';

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'");
});
});
});
}

0 comments on commit 094ea68

Please sign in to comment.