| 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 ff0a308a1d096ca5823b48dd4b0fc209033d0649..181fc54f0f8c7cec383a2c24ab4c7658a30e265a 100644
|
| --- a/pkg/analyzer/test/file_system/physical_resource_provider_test.dart
|
| +++ b/pkg/analyzer/test/file_system/physical_resource_provider_test.dart
|
| @@ -132,6 +132,46 @@ class FileTest extends _BaseTest {
|
| expect(file.readAsStringSync(), 'abc');
|
| }
|
|
|
| + void test_renameSync_newDoesNotExist() {
|
| + String oldPath = '$tempPath/file.txt';
|
| + String newPath = '$tempPath/new-file.txt';
|
| + new io.File(oldPath).writeAsStringSync('text');
|
| + File file = PhysicalResourceProvider.INSTANCE.getResource(oldPath);
|
| + File newFile = file.renameSync(newPath);
|
| + expect(file.path, oldPath);
|
| + expect(file.exists, isFalse);
|
| + expect(newFile.path, newPath);
|
| + expect(newFile.exists, isTrue);
|
| + expect(newFile.readAsStringSync(), 'text');
|
| + }
|
| +
|
| + void test_renameSync_newExists_file() {
|
| + String oldPath = '$tempPath/file.txt';
|
| + String newPath = '$tempPath/new-file.txt';
|
| + new io.File(oldPath).writeAsStringSync('text');
|
| + new io.File(newPath).writeAsStringSync('new text');
|
| + File file = PhysicalResourceProvider.INSTANCE.getResource(oldPath);
|
| + File newFile = file.renameSync(newPath);
|
| + expect(file.path, oldPath);
|
| + expect(file.exists, isFalse);
|
| + expect(newFile.path, newPath);
|
| + expect(newFile.exists, isTrue);
|
| + expect(newFile.readAsStringSync(), 'text');
|
| + }
|
| +
|
| + void test_renameSync_newExists_folder() {
|
| + String oldPath = '$tempPath/file.txt';
|
| + String newPath = '$tempPath/foo';
|
| + new io.File(oldPath).writeAsStringSync('text');
|
| + new io.Directory(newPath).createSync();
|
| + File file = PhysicalResourceProvider.INSTANCE.getResource(oldPath);
|
| + expect(() {
|
| + file.renameSync(newPath);
|
| + }, throwsA(_isFileSystemException));
|
| + expect(file.path, oldPath);
|
| + expect(file.exists, isTrue);
|
| + }
|
| +
|
| void test_shortName() {
|
| expect(file.shortName, 'file.txt');
|
| }
|
|
|