| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // SharedOptions=--supermixin | 4 // SharedOptions=--supermixin |
| 5 | 5 |
| 6 library front_end.test.memory_file_system_test; | 6 library front_end.test.memory_file_system_test; |
| 7 | 7 |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class FileTest extends _BaseTestNative { | 30 class FileTest extends _BaseTestNative { |
| 31 String path; | 31 String path; |
| 32 MemoryFileSystemEntity file; | 32 MemoryFileSystemEntity file; |
| 33 | 33 |
| 34 setUp() { | 34 setUp() { |
| 35 super.setUp(); | 35 super.setUp(); |
| 36 path = join(tempPath, 'file.txt'); | 36 path = join(tempPath, 'file.txt'); |
| 37 file = entityForPath(path); | 37 file = entityForPath(path); |
| 38 } | 38 } |
| 39 | 39 |
| 40 test_createDirectory_doesNotExist() async { |
| 41 file.createDirectory(); |
| 42 expect(await file.exists(), true); |
| 43 } |
| 44 |
| 45 test_createDirectory_exists_asDirectory() async { |
| 46 file.createDirectory(); |
| 47 expect(() => file.createDirectory(), _throwsFileSystemException); |
| 48 } |
| 49 |
| 50 test_createDirectory_exists_asFile() async { |
| 51 file.writeAsStringSync(''); |
| 52 expect(() => file.createDirectory(), _throwsFileSystemException); |
| 53 } |
| 54 |
| 40 test_equals_differentPaths() { | 55 test_equals_differentPaths() { |
| 41 expect(file == entityForPath(join(tempPath, 'file2.txt')), isFalse); | 56 expect(file == entityForPath(join(tempPath, 'file2.txt')), isFalse); |
| 42 } | 57 } |
| 43 | 58 |
| 44 test_equals_samePath() { | 59 test_equals_samePath() { |
| 45 expect(file == entityForPath(join(tempPath, 'file.txt')), isTrue); | 60 expect(file == entityForPath(join(tempPath, 'file.txt')), isTrue); |
| 46 } | 61 } |
| 47 | 62 |
| 63 test_exists_directory_exists() async { |
| 64 file.createDirectory(); |
| 65 expect(await file.exists(), true); |
| 66 } |
| 67 |
| 48 test_exists_doesNotExist() async { | 68 test_exists_doesNotExist() async { |
| 49 expect(await file.exists(), false); | 69 expect(await file.exists(), false); |
| 50 } | 70 } |
| 51 | 71 |
| 52 test_exists_exists() async { | 72 test_exists_file_exists() async { |
| 53 file.writeAsStringSync('x'); | 73 file.writeAsStringSync('x'); |
| 54 expect(await file.exists(), true); | 74 expect(await file.exists(), true); |
| 55 } | 75 } |
| 56 | 76 |
| 57 test_hashCode_samePath() { | 77 test_hashCode_samePath() { |
| 58 expect(file.hashCode, entityForPath(join(tempPath, 'file.txt')).hashCode); | 78 expect(file.hashCode, entityForPath(join(tempPath, 'file.txt')).hashCode); |
| 59 } | 79 } |
| 60 | 80 |
| 61 test_path() { | 81 test_path() { |
| 62 expect(file.uri, context.toUri(path)); | 82 expect(file.uri, context.toUri(path)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 92 var s = 'contents'; | 112 var s = 'contents'; |
| 93 file.writeAsStringSync(s); | 113 file.writeAsStringSync(s); |
| 94 expect(await file.readAsString(), s); | 114 expect(await file.readAsString(), s); |
| 95 } | 115 } |
| 96 | 116 |
| 97 test_readAsString_utf8() async { | 117 test_readAsString_utf8() async { |
| 98 file.writeAsBytesSync([0xe2, 0x82, 0xac]); // Unicode € symbol, in UTF-8 | 118 file.writeAsBytesSync([0xe2, 0x82, 0xac]); // Unicode € symbol, in UTF-8 |
| 99 expect(await file.readAsString(), '\u20ac'); | 119 expect(await file.readAsString(), '\u20ac'); |
| 100 } | 120 } |
| 101 | 121 |
| 122 test_writeAsBytesSync_directory() async { |
| 123 file.createDirectory(); |
| 124 expect(() => file.writeAsBytesSync([0]), _throwsFileSystemException); |
| 125 } |
| 126 |
| 102 test_writeAsBytesSync_modifyAfterRead() async { | 127 test_writeAsBytesSync_modifyAfterRead() async { |
| 103 file.writeAsBytesSync([1]); | 128 file.writeAsBytesSync([1]); |
| 104 (await file.readAsBytes())[0] = 2; | 129 (await file.readAsBytes())[0] = 2; |
| 105 expect(await file.readAsBytes(), [1]); | 130 expect(await file.readAsBytes(), [1]); |
| 106 } | 131 } |
| 107 | 132 |
| 108 test_writeAsBytesSync_modifyAfterWrite() async { | 133 test_writeAsBytesSync_modifyAfterWrite() async { |
| 109 var bytes = [1]; | 134 var bytes = [1]; |
| 110 file.writeAsBytesSync(bytes); | 135 file.writeAsBytesSync(bytes); |
| 111 bytes[0] = 2; | 136 bytes[0] = 2; |
| 112 expect(await file.readAsBytes(), [1]); | 137 expect(await file.readAsBytes(), [1]); |
| 113 } | 138 } |
| 114 | 139 |
| 115 test_writeAsBytesSync_overwrite() async { | 140 test_writeAsBytesSync_overwrite() async { |
| 116 file.writeAsBytesSync([1]); | 141 file.writeAsBytesSync([1]); |
| 117 file.writeAsBytesSync([2]); | 142 file.writeAsBytesSync([2]); |
| 118 expect(await file.readAsBytes(), [2]); | 143 expect(await file.readAsBytes(), [2]); |
| 119 } | 144 } |
| 120 | 145 |
| 146 test_writeAsStringSync_directory() async { |
| 147 file.createDirectory(); |
| 148 expect(() => file.writeAsStringSync(''), _throwsFileSystemException); |
| 149 } |
| 150 |
| 121 test_writeAsStringSync_overwrite() async { | 151 test_writeAsStringSync_overwrite() async { |
| 122 file.writeAsStringSync('first'); | 152 file.writeAsStringSync('first'); |
| 123 file.writeAsStringSync('second'); | 153 file.writeAsStringSync('second'); |
| 124 expect(await file.readAsString(), 'second'); | 154 expect(await file.readAsString(), 'second'); |
| 125 } | 155 } |
| 126 | 156 |
| 127 test_writeAsStringSync_utf8() async { | 157 test_writeAsStringSync_utf8() async { |
| 128 file.writeAsStringSync('\u20ac'); // Unicode € symbol | 158 file.writeAsStringSync('\u20ac'); // Unicode € symbol |
| 129 expect(await file.readAsBytes(), [0xe2, 0x82, 0xac]); | 159 expect(await file.readAsBytes(), [0xe2, 0x82, 0xac]); |
| 130 } | 160 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 String tempPath; | 299 String tempPath; |
| 270 | 300 |
| 271 String join(String path1, String path2, [String path3, String path4]) => | 301 String join(String path1, String path2, [String path3, String path4]) => |
| 272 pathos.windows.join(path1, path2, path3, path4); | 302 pathos.windows.join(path1, path2, path3, path4); |
| 273 | 303 |
| 274 void setUp() { | 304 void setUp() { |
| 275 tempPath = r'c:\test_file_system'; | 305 tempPath = r'c:\test_file_system'; |
| 276 fileSystem = new MemoryFileSystem(Uri.parse('file:///c:/cwd')); | 306 fileSystem = new MemoryFileSystem(Uri.parse('file:///c:/cwd')); |
| 277 } | 307 } |
| 278 } | 308 } |
| OLD | NEW |