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

Unified Diff: pkg/analyzer/test/file_system/memory_file_system_test.dart

Issue 2265593002: Add writeAsStringSync (issue 27109) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/file_system/memory_file_system_test.dart
diff --git a/pkg/analyzer/test/file_system/memory_file_system_test.dart b/pkg/analyzer/test/file_system/memory_file_system_test.dart
index 5c931b144489e8ba1ae3bcb187f4b4fd9d9d3159..2ee57753d04e487af650dc33206b92091ed1d43f 100644
--- a/pkg/analyzer/test/file_system/memory_file_system_test.dart
+++ b/pkg/analyzer/test/file_system/memory_file_system_test.dart
@@ -211,20 +211,43 @@ class FileTest {
}
void test_writeAsBytesSync_existing() {
- File file = provider.newFileWithBytes('/foo/file.bin', <int>[1, 2]);
- expect(file.readAsBytesSync(), <int>[1, 2]);
+ List<int> content = <int>[1, 2];
+ File file = provider.newFileWithBytes('/foo/file.bin', content);
+ expect(file.readAsBytesSync(), content);
// write new bytes
- file.writeAsBytesSync(<int>[10, 20]);
- expect(file.readAsBytesSync(), <int>[10, 20]);
+ content = <int>[10, 20];
+ file.writeAsBytesSync(content);
+ expect(file.readAsBytesSync(), content);
}
void test_writeAsBytesSync_new() {
File file = provider.getFile('/foo/file.bin');
expect(file.exists, false);
// write new bytes
- file.writeAsBytesSync(<int>[10, 20]);
+ List<int> content = <int>[10, 20];
+ file.writeAsBytesSync(content);
expect(file.exists, true);
- expect(file.readAsBytesSync(), <int>[10, 20]);
+ expect(file.readAsBytesSync(), content);
+ }
+
+ void test_writeAsStringSync_existing() {
+ String content = 'ab';
+ File file = provider.newFile('/foo/file.txt', content);
+ expect(file.readAsStringSync(), content);
+ // write new bytes
+ content = 'CD';
+ file.writeAsStringSync(content);
+ expect(file.readAsStringSync(), content);
+ }
+
+ void test_writeAsStringSync_new() {
+ File file = provider.getFile('/foo/file.txt');
+ expect(file.exists, false);
+ // write new bytes
+ String content = 'ef';
+ file.writeAsStringSync(content);
+ expect(file.exists, true);
+ expect(file.readAsStringSync(), content);
}
}

Powered by Google App Engine
This is Rietveld 408576698