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

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

Issue 1811643002: Add File.readAsBytesSync/writeAsBytesSync() methods. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/file_system/memory_file_system_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/file_system/physical_resource_provider_test.dart
diff --git a/pkg/analyzer/test/file_system/physical_resource_provider_test.dart b/pkg/analyzer/test/file_system/physical_resource_provider_test.dart
index 850bbcf3fecc6f3814e89aa7a485e21a9a4cfb5f..ff0a308a1d096ca5823b48dd4b0fc209033d0649 100644
--- a/pkg/analyzer/test/file_system/physical_resource_provider_test.dart
+++ b/pkg/analyzer/test/file_system/physical_resource_provider_test.dart
@@ -20,9 +20,11 @@ import '../utils.dart';
main() {
initializeTestEnvironment();
- runReflectiveTests(PhysicalResourceProviderTest);
- runReflectiveTests(FileTest);
- runReflectiveTests(FolderTest);
+ if (!new bool.fromEnvironment('skipPhysicalResourceProviderTests')) {
+ runReflectiveTests(PhysicalResourceProviderTest);
+ runReflectiveTests(FileTest);
+ runReflectiveTests(FolderTest);
+ }
}
var _isFile = new isInstanceOf<File>();
@@ -104,6 +106,19 @@ class FileTest extends _BaseTest {
expect(parent.path, equals(tempPath));
}
+ void test_readAsBytesSync_doesNotExist() {
+ File file = PhysicalResourceProvider.INSTANCE.getResource('/test.bin');
+ expect(() {
+ file.readAsBytesSync();
+ }, throwsA(_isFileSystemException));
+ }
+
+ void test_readAsBytesSync_exists() {
+ List<int> bytes = <int>[1, 2, 3, 4, 5];
+ new io.File(path).writeAsBytesSync(bytes);
+ expect(file.readAsBytesSync(), bytes);
+ }
+
void test_readAsStringSync_doesNotExist() {
File file = PhysicalResourceProvider.INSTANCE.getResource(path);
expect(() {
@@ -124,6 +139,14 @@ class FileTest extends _BaseTest {
void test_toString() {
expect(file.toString(), path);
}
+
+ void test_writeAsBytesSync() {
+ new io.File(path).writeAsBytesSync(<int>[1, 2]);
+ expect(file.readAsBytesSync(), <int>[1, 2]);
+ // write new bytes
+ file.writeAsBytesSync(<int>[10, 20]);
+ expect(file.readAsBytesSync(), <int>[10, 20]);
+ }
}
@reflectiveTest
« no previous file with comments | « pkg/analyzer/test/file_system/memory_file_system_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698