OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // | 4 // |
5 // Dart test program for testing error handling in file I/O. | 5 // Dart test program for testing error handling in file I/O. |
6 | 6 |
7 import "dart:convert"; | 7 import "dart:convert"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
11 import "package:expect/expect.dart"; | 11 import "package:expect/expect.dart"; |
12 | 12 |
13 Directory tempDir() { | 13 Directory tempDir() { |
14 return Directory.systemTemp.createTempSync('dart_file_error'); | 14 return Directory.systemTemp.createTempSync('dart_file_error'); |
15 } | 15 } |
16 | 16 |
17 | 17 |
18 bool checkNonExistentFileException(e, str) { | 18 bool checkNonExistentFileSystemException(e, str) { |
19 Expect.isTrue(e is FileException); | 19 Expect.isTrue(e is FileSystemException); |
20 Expect.isTrue(e.osError != null); | 20 Expect.isTrue(e.osError != null); |
21 Expect.isTrue(e.toString().indexOf(str) != -1); | 21 Expect.isTrue(e.toString().indexOf(str) != -1); |
22 // File not not found has error code 2 on all supported platforms. | 22 // File not not found has error code 2 on all supported platforms. |
23 Expect.equals(2, e.osError.errorCode); | 23 Expect.equals(2, e.osError.errorCode); |
24 return true; | 24 return true; |
25 } | 25 } |
26 | 26 |
27 | 27 |
28 bool checkOpenNonExistentFileException(e) { | 28 bool checkOpenNonExistentFileSystemException(e) { |
29 return checkNonExistentFileException(e, "Cannot open file"); | 29 return checkNonExistentFileSystemException(e, "Cannot open file"); |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 bool checkDeleteNonExistentFileException(e) { | 33 bool checkDeleteNonExistentFileSystemException(e) { |
34 return checkNonExistentFileException(e, "Cannot delete file"); | 34 return checkNonExistentFileSystemException(e, "Cannot delete file"); |
35 } | 35 } |
36 | 36 |
37 | 37 |
38 bool checkLengthNonExistentFileException(e) { | 38 bool checkLengthNonExistentFileSystemException(e) { |
39 return checkNonExistentFileException(e, "Cannot retrieve length of file"); | 39 return checkNonExistentFileSystemException(e, "Cannot retrieve length of file"
); |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 void testOpenNonExistent() { | 43 void testOpenNonExistent() { |
44 asyncStart(); | 44 asyncStart(); |
45 Directory temp = tempDir(); | 45 Directory temp = tempDir(); |
46 var file = new File("${temp.path}/nonExistentFile"); | 46 var file = new File("${temp.path}/nonExistentFile"); |
47 | 47 |
48 // Non-existing file should throw exception. | 48 // Non-existing file should throw exception. |
49 Expect.throws(() => file.openSync(), | 49 Expect.throws(() => file.openSync(), |
50 (e) => checkOpenNonExistentFileException(e)); | 50 (e) => checkOpenNonExistentFileSystemException(e)); |
51 | 51 |
52 var openFuture = file.open(mode: FileMode.READ); | 52 var openFuture = file.open(mode: FileMode.READ); |
53 openFuture.then((raf) => Expect.fail("Unreachable code")) | 53 openFuture.then((raf) => Expect.fail("Unreachable code")) |
54 .catchError((error) { | 54 .catchError((error) { |
55 checkOpenNonExistentFileException(error); | 55 checkOpenNonExistentFileSystemException(error); |
56 temp.deleteSync(recursive: true); | 56 temp.deleteSync(recursive: true); |
57 asyncEnd(); | 57 asyncEnd(); |
58 }); | 58 }); |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 void testDeleteNonExistent() { | 62 void testDeleteNonExistent() { |
63 asyncStart(); | 63 asyncStart(); |
64 Directory temp = tempDir(); | 64 Directory temp = tempDir(); |
65 var file = new File("${temp.path}/nonExistentFile"); | 65 var file = new File("${temp.path}/nonExistentFile"); |
66 | 66 |
67 // Non-existing file should throw exception. | 67 // Non-existing file should throw exception. |
68 Expect.throws(() => file.deleteSync(), | 68 Expect.throws(() => file.deleteSync(), |
69 (e) => checkDeleteNonExistentFileException(e)); | 69 (e) => checkDeleteNonExistentFileSystemException(e)); |
70 | 70 |
71 var delete = file.delete(); | 71 var delete = file.delete(); |
72 delete.then((ignore) => Expect.fail("Unreachable code")) | 72 delete.then((ignore) => Expect.fail("Unreachable code")) |
73 .catchError((error) { | 73 .catchError((error) { |
74 checkDeleteNonExistentFileException(error); | 74 checkDeleteNonExistentFileSystemException(error); |
75 temp.deleteSync(recursive: true); | 75 temp.deleteSync(recursive: true); |
76 asyncEnd(); | 76 asyncEnd(); |
77 }); | 77 }); |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 void testLengthNonExistent() { | 81 void testLengthNonExistent() { |
82 asyncStart(); | 82 asyncStart(); |
83 Directory temp = tempDir(); | 83 Directory temp = tempDir(); |
84 var file = new File("${temp.path}/nonExistentFile"); | 84 var file = new File("${temp.path}/nonExistentFile"); |
85 | 85 |
86 // Non-existing file should throw exception. | 86 // Non-existing file should throw exception. |
87 Expect.throws(() => file.lengthSync(), | 87 Expect.throws(() => file.lengthSync(), |
88 (e) => checkLengthNonExistentFileException(e)); | 88 (e) => checkLengthNonExistentFileSystemException(e)); |
89 | 89 |
90 var lenFuture = file.length(); | 90 var lenFuture = file.length(); |
91 lenFuture.then((len) => Expect.fail("Unreachable code")) | 91 lenFuture.then((len) => Expect.fail("Unreachable code")) |
92 .catchError((error) { | 92 .catchError((error) { |
93 checkLengthNonExistentFileException(error); | 93 checkLengthNonExistentFileSystemException(error); |
94 temp.deleteSync(recursive: true); | 94 temp.deleteSync(recursive: true); |
95 asyncEnd(); | 95 asyncEnd(); |
96 }); | 96 }); |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 bool checkCreateInNonExistentDirectoryException(e) { | 100 bool checkCreateInNonExistentFileSystemException(e) { |
101 Expect.isTrue(e is FileException); | 101 Expect.isTrue(e is FileSystemException); |
102 Expect.isTrue(e.osError != null); | 102 Expect.isTrue(e.osError != null); |
103 Expect.isTrue(e.toString().indexOf("Cannot create file") != -1); | 103 Expect.isTrue(e.toString().indexOf("Cannot create file") != -1); |
104 if (Platform.operatingSystem == "linux") { | 104 if (Platform.operatingSystem == "linux") { |
105 Expect.equals(2, e.osError.errorCode); | 105 Expect.equals(2, e.osError.errorCode); |
106 } else if (Platform.operatingSystem == "macos") { | 106 } else if (Platform.operatingSystem == "macos") { |
107 Expect.equals(2, e.osError.errorCode); | 107 Expect.equals(2, e.osError.errorCode); |
108 } else if (Platform.operatingSystem == "windows") { | 108 } else if (Platform.operatingSystem == "windows") { |
109 Expect.equals(3, e.osError.errorCode); | 109 Expect.equals(3, e.osError.errorCode); |
110 } | 110 } |
111 | 111 |
112 return true; | 112 return true; |
113 } | 113 } |
114 | 114 |
115 void testCreateInNonExistentDirectory() { | 115 void testCreateInNonExistentDirectory() { |
116 asyncStart(); | 116 asyncStart(); |
117 Directory temp = tempDir(); | 117 Directory temp = tempDir(); |
118 var file = new File("${temp.path}/nonExistentDirectory/newFile"); | 118 var file = new File("${temp.path}/nonExistentDirectory/newFile"); |
119 | 119 |
120 // Create in non-existent directory should throw exception. | 120 // Create in non-existent directory should throw exception. |
121 Expect.throws(() => file.createSync(), | 121 Expect.throws(() => file.createSync(), |
122 (e) => checkCreateInNonExistentDirectoryException(e)); | 122 (e) => checkCreateInNonExistentFileSystemException(e)); |
123 | 123 |
124 var create = file.create(); | 124 var create = file.create(); |
125 create.then((ignore) => Expect.fail("Unreachable code")) | 125 create.then((ignore) => Expect.fail("Unreachable code")) |
126 .catchError((error) { | 126 .catchError((error) { |
127 checkCreateInNonExistentDirectoryException(error); | 127 checkCreateInNonExistentFileSystemException(error); |
128 temp.deleteSync(recursive: true); | 128 temp.deleteSync(recursive: true); |
129 asyncEnd(); | 129 asyncEnd(); |
130 }); | 130 }); |
131 } | 131 } |
132 | 132 |
133 bool checkResolveSymbolicLinksOnNonExistentDirectoryException(e) { | 133 bool checkResolveSymbolicLinksOnNonExistentFileSystemException(e) { |
134 Expect.isTrue(e is FileException); | 134 Expect.isTrue(e is FileSystemException); |
135 Expect.isTrue(e.osError != null); | 135 Expect.isTrue(e.osError != null); |
136 Expect.isTrue(e.toString().indexOf("Cannot resolve symbolic links") != -1); | 136 Expect.isTrue(e.toString().indexOf("Cannot resolve symbolic links") != -1); |
137 // File not not found has error code 2 on all supported platforms. | 137 // File not not found has error code 2 on all supported platforms. |
138 Expect.equals(2, e.osError.errorCode); | 138 Expect.equals(2, e.osError.errorCode); |
139 | 139 |
140 return true; | 140 return true; |
141 } | 141 } |
142 | 142 |
143 void testResolveSymbolicLinksOnNonExistentDirectory() { | 143 void testResolveSymbolicLinksOnNonExistentDirectory() { |
144 asyncStart(); | 144 asyncStart(); |
145 Directory temp = tempDir(); | 145 Directory temp = tempDir(); |
146 var file = new File("${temp.path}/nonExistentDirectory"); | 146 var file = new File("${temp.path}/nonExistentDirectory"); |
147 | 147 |
148 // Full path non-existent directory should throw exception. | 148 // Full path non-existent directory should throw exception. |
149 Expect.throws(() => file.resolveSymbolicLinksSync(), | 149 Expect.throws(() => file.resolveSymbolicLinksSync(), |
150 (e) => checkResolveSymbolicLinksOnNonExistentDirectoryException(e)); | 150 (e) => checkResolveSymbolicLinksOnNonExistentFileSystemException(e)); |
151 | 151 |
152 var resolvedFuture = file.resolveSymbolicLinks(); | 152 var resolvedFuture = file.resolveSymbolicLinks(); |
153 resolvedFuture.then((path) => Expect.fail("Unreachable code $path")) | 153 resolvedFuture.then((path) => Expect.fail("Unreachable code $path")) |
154 .catchError((error) { | 154 .catchError((error) { |
155 checkResolveSymbolicLinksOnNonExistentDirectoryException(error); | 155 checkResolveSymbolicLinksOnNonExistentFileSystemException(error); |
156 temp.deleteSync(recursive: true); | 156 temp.deleteSync(recursive: true); |
157 asyncEnd(); | 157 asyncEnd(); |
158 }); | 158 }); |
159 } | 159 } |
160 | 160 |
161 void testReadAsBytesNonExistent() { | 161 void testReadAsBytesNonExistent() { |
162 asyncStart(); | 162 asyncStart(); |
163 Directory temp = tempDir(); | 163 Directory temp = tempDir(); |
164 var file = new File("${temp.path}/nonExistentFile3"); | 164 var file = new File("${temp.path}/nonExistentFile3"); |
165 | 165 |
166 // Non-existing file should throw exception. | 166 // Non-existing file should throw exception. |
167 Expect.throws(() => file.readAsBytesSync(), | 167 Expect.throws(() => file.readAsBytesSync(), |
168 (e) => checkOpenNonExistentFileException(e)); | 168 (e) => checkOpenNonExistentFileSystemException(e)); |
169 | 169 |
170 var readAsBytesFuture = file.readAsBytes(); | 170 var readAsBytesFuture = file.readAsBytes(); |
171 readAsBytesFuture.then((data) => Expect.fail("Unreachable code")) | 171 readAsBytesFuture.then((data) => Expect.fail("Unreachable code")) |
172 .catchError((error) { | 172 .catchError((error) { |
173 checkOpenNonExistentFileException(error); | 173 checkOpenNonExistentFileSystemException(error); |
174 temp.deleteSync(recursive: true); | 174 temp.deleteSync(recursive: true); |
175 asyncEnd(); | 175 asyncEnd(); |
176 }); | 176 }); |
177 } | 177 } |
178 | 178 |
179 void testReadAsTextNonExistent() { | 179 void testReadAsTextNonExistent() { |
180 asyncStart(); | 180 asyncStart(); |
181 Directory temp = tempDir(); | 181 Directory temp = tempDir(); |
182 var file = new File("${temp.path}/nonExistentFile4"); | 182 var file = new File("${temp.path}/nonExistentFile4"); |
183 | 183 |
184 // Non-existing file should throw exception. | 184 // Non-existing file should throw exception. |
185 Expect.throws(() => file.readAsStringSync(), | 185 Expect.throws(() => file.readAsStringSync(), |
186 (e) => checkOpenNonExistentFileException(e)); | 186 (e) => checkOpenNonExistentFileSystemException(e)); |
187 | 187 |
188 var readAsStringFuture = file.readAsString(encoding: ASCII); | 188 var readAsStringFuture = file.readAsString(encoding: ASCII); |
189 readAsStringFuture.then((data) => Expect.fail("Unreachable code")) | 189 readAsStringFuture.then((data) => Expect.fail("Unreachable code")) |
190 .catchError((error) { | 190 .catchError((error) { |
191 checkOpenNonExistentFileException(error); | 191 checkOpenNonExistentFileSystemException(error); |
192 temp.deleteSync(recursive: true); | 192 temp.deleteSync(recursive: true); |
193 asyncEnd(); | 193 asyncEnd(); |
194 }); | 194 }); |
195 } | 195 } |
196 | 196 |
197 testReadAsLinesNonExistent() { | 197 testReadAsLinesNonExistent() { |
198 asyncStart(); | 198 asyncStart(); |
199 Directory temp = tempDir(); | 199 Directory temp = tempDir(); |
200 var file = new File("${temp.path}/nonExistentFile5"); | 200 var file = new File("${temp.path}/nonExistentFile5"); |
201 | 201 |
202 // Non-existing file should throw exception. | 202 // Non-existing file should throw exception. |
203 Expect.throws(() => file.readAsLinesSync(), | 203 Expect.throws(() => file.readAsLinesSync(), |
204 (e) => checkOpenNonExistentFileException(e)); | 204 (e) => checkOpenNonExistentFileSystemException(e)); |
205 | 205 |
206 var readAsLinesFuture = file.readAsLines(encoding: ASCII); | 206 var readAsLinesFuture = file.readAsLines(encoding: ASCII); |
207 readAsLinesFuture.then((data) => Expect.fail("Unreachable code")) | 207 readAsLinesFuture.then((data) => Expect.fail("Unreachable code")) |
208 .catchError((error) { | 208 .catchError((error) { |
209 checkOpenNonExistentFileException(error); | 209 checkOpenNonExistentFileSystemException(error); |
210 temp.deleteSync(recursive: true); | 210 temp.deleteSync(recursive: true); |
211 asyncEnd(); | 211 asyncEnd(); |
212 }); | 212 }); |
213 } | 213 } |
214 | 214 |
215 bool checkWriteReadOnlyFileException(e) { | 215 bool checkWriteReadOnlyFileSystemException(e) { |
216 Expect.isTrue(e is FileException); | 216 Expect.isTrue(e is FileSystemException); |
217 Expect.isTrue(e.osError != null); | 217 Expect.isTrue(e.osError != null); |
218 Expect.isTrue(e.osError.errorCode != OSError.noErrorCode); | 218 Expect.isTrue(e.osError.errorCode != OSError.noErrorCode); |
219 return true; | 219 return true; |
220 } | 220 } |
221 | 221 |
222 | 222 |
223 // Create a test file in a temporary directory. Setup a port to signal | 223 // Create a test file in a temporary directory. Setup a port to signal |
224 // when the temporary directory should be deleted. Pass the file and | 224 // when the temporary directory should be deleted. Pass the file and |
225 // the port to the callback argument. | 225 // the port to the callback argument. |
226 createTestFile(callback) { | 226 createTestFile(callback) { |
227 asyncStart(); | 227 asyncStart(); |
228 Directory temp = tempDir(); | 228 Directory temp = tempDir(); |
229 var file = new File("${temp.path}/test_file"); | 229 var file = new File("${temp.path}/test_file"); |
230 file.createSync(); | 230 file.createSync(); |
231 callback(file, () { | 231 callback(file, () { |
232 temp.deleteSync(recursive: true); | 232 temp.deleteSync(recursive: true); |
233 asyncEnd(); | 233 asyncEnd(); |
234 }); | 234 }); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 testWriteByteToReadOnlyFile() { | 238 testWriteByteToReadOnlyFile() { |
239 createTestFile((file, done) { | 239 createTestFile((file, done) { |
240 var openedFile = file.openSync(mode: FileMode.READ); | 240 var openedFile = file.openSync(mode: FileMode.READ); |
241 | 241 |
242 // Writing to read only file should throw an exception. | 242 // Writing to read only file should throw an exception. |
243 Expect.throws(() => openedFile.writeByteSync(0), | 243 Expect.throws(() => openedFile.writeByteSync(0), |
244 (e) => checkWriteReadOnlyFileException(e)); | 244 (e) => checkWriteReadOnlyFileSystemException(e)); |
245 | 245 |
246 var writeByteFuture = openedFile.writeByte(0); | 246 var writeByteFuture = openedFile.writeByte(0); |
247 writeByteFuture.catchError((error) { | 247 writeByteFuture.catchError((error) { |
248 checkWriteReadOnlyFileException(error); | 248 checkWriteReadOnlyFileSystemException(error); |
249 openedFile.close().then((_) => done()); | 249 openedFile.close().then((_) => done()); |
250 }); | 250 }); |
251 }); | 251 }); |
252 } | 252 } |
253 | 253 |
254 testWriteFromToReadOnlyFile() { | 254 testWriteFromToReadOnlyFile() { |
255 createTestFile((file, done) { | 255 createTestFile((file, done) { |
256 var openedFile = file.openSync(mode: FileMode.READ); | 256 var openedFile = file.openSync(mode: FileMode.READ); |
257 | 257 |
258 List data = [0, 1, 2, 3]; | 258 List data = [0, 1, 2, 3]; |
259 // Writing to read only file should throw an exception. | 259 // Writing to read only file should throw an exception. |
260 Expect.throws(() => openedFile.writeFromSync(data, 0, data.length), | 260 Expect.throws(() => openedFile.writeFromSync(data, 0, data.length), |
261 (e) => checkWriteReadOnlyFileException(e)); | 261 (e) => checkWriteReadOnlyFileSystemException(e)); |
262 | 262 |
263 var writeFromFuture = openedFile.writeFrom(data, 0, data.length); | 263 var writeFromFuture = openedFile.writeFrom(data, 0, data.length); |
264 writeFromFuture.catchError((error) { | 264 writeFromFuture.catchError((error) { |
265 checkWriteReadOnlyFileException(error); | 265 checkWriteReadOnlyFileSystemException(error); |
266 openedFile.close().then((_) => done()); | 266 openedFile.close().then((_) => done()); |
267 }); | 267 }); |
268 }); | 268 }); |
269 } | 269 } |
270 | 270 |
271 testTruncateReadOnlyFile() { | 271 testTruncateReadOnlyFile() { |
272 createTestFile((file, done) { | 272 createTestFile((file, done) { |
273 var openedFile = file.openSync(mode: FileMode.WRITE); | 273 var openedFile = file.openSync(mode: FileMode.WRITE); |
274 openedFile.writeByteSync(0); | 274 openedFile.writeByteSync(0); |
275 openedFile.closeSync(); | 275 openedFile.closeSync(); |
276 openedFile = file.openSync(mode: FileMode.READ); | 276 openedFile = file.openSync(mode: FileMode.READ); |
277 | 277 |
278 // Truncating read only file should throw an exception. | 278 // Truncating read only file should throw an exception. |
279 Expect.throws(() => openedFile.truncateSync(0), | 279 Expect.throws(() => openedFile.truncateSync(0), |
280 (e) => checkWriteReadOnlyFileException(e)); | 280 (e) => checkWriteReadOnlyFileSystemException(e)); |
281 | 281 |
282 var truncateFuture = openedFile.truncate(0); | 282 var truncateFuture = openedFile.truncate(0); |
283 truncateFuture.then((ignore) => Expect.fail("Unreachable code")) | 283 truncateFuture.then((ignore) => Expect.fail("Unreachable code")) |
284 .catchError((error) { | 284 .catchError((error) { |
285 checkWriteReadOnlyFileException(error); | 285 checkWriteReadOnlyFileSystemException(error); |
286 openedFile.close().then((_) => done()); | 286 openedFile.close().then((_) => done()); |
287 }); | 287 }); |
288 }); | 288 }); |
289 } | 289 } |
290 | 290 |
291 bool checkFileClosedException(e) { | 291 bool checkFileClosedException(e) { |
292 Expect.isTrue(e is FileException); | 292 Expect.isTrue(e is FileSystemException); |
293 Expect.isTrue(e.toString().indexOf("File closed") != -1); | 293 Expect.isTrue(e.toString().indexOf("File closed") != -1); |
294 Expect.isTrue(e.osError == null); | 294 Expect.isTrue(e.osError == null); |
295 return true; | 295 return true; |
296 } | 296 } |
297 | 297 |
298 testOperateOnClosedFile() { | 298 testOperateOnClosedFile() { |
299 createTestFile((file, done) { | 299 createTestFile((file, done) { |
300 var openedFile = file.openSync(mode: FileMode.READ); | 300 var openedFile = file.openSync(mode: FileMode.READ); |
301 openedFile.closeSync(); | 301 openedFile.closeSync(); |
302 | 302 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 }); | 374 }); |
375 } | 375 } |
376 | 376 |
377 testRepeatedlyCloseFile() { | 377 testRepeatedlyCloseFile() { |
378 createTestFile((file, done) { | 378 createTestFile((file, done) { |
379 var openedFile = file.openSync(); | 379 var openedFile = file.openSync(); |
380 openedFile.close().then((ignore) { | 380 openedFile.close().then((ignore) { |
381 var closeFuture = openedFile.close(); | 381 var closeFuture = openedFile.close(); |
382 closeFuture.then((ignore) => null) | 382 closeFuture.then((ignore) => null) |
383 .catchError((error) { | 383 .catchError((error) { |
384 Expect.isTrue(error is FileException); | 384 Expect.isTrue(error is FileSystemException); |
385 done(); | 385 done(); |
386 }); | 386 }); |
387 }); | 387 }); |
388 }); | 388 }); |
389 } | 389 } |
390 | 390 |
391 testRepeatedlyCloseFileSync() { | 391 testRepeatedlyCloseFileSync() { |
392 createTestFile((file, done) { | 392 createTestFile((file, done) { |
393 var openedFile = file.openSync(); | 393 var openedFile = file.openSync(); |
394 openedFile.closeSync(); | 394 openedFile.closeSync(); |
395 Expect.throws(openedFile.closeSync, | 395 Expect.throws(openedFile.closeSync, |
396 (e) => e is FileException); | 396 (e) => e is FileSystemException); |
397 done(); | 397 done(); |
398 }); | 398 }); |
399 } | 399 } |
400 | 400 |
401 testReadSyncBigInt() { | 401 testReadSyncBigInt() { |
402 createTestFile((file, done) { | 402 createTestFile((file, done) { |
403 var bigint = 100000000000000000000000000000000000000000; | 403 var bigint = 100000000000000000000000000000000000000000; |
404 var openedFile = file.openSync(); | 404 var openedFile = file.openSync(); |
405 Expect.throws(() => openedFile.readSync(bigint), | 405 Expect.throws(() => openedFile.readSync(bigint), |
406 (e) => e is FileException); | 406 (e) => e is FileSystemException); |
407 openedFile.closeSync(); | 407 openedFile.closeSync(); |
408 done(); | 408 done(); |
409 }); | 409 }); |
410 } | 410 } |
411 | 411 |
412 testReadSyncClosedFile() { | 412 testReadSyncClosedFile() { |
413 createTestFile((file, done) { | 413 createTestFile((file, done) { |
414 var openedFile = file.openSync(); | 414 var openedFile = file.openSync(); |
415 openedFile.closeSync(); | 415 openedFile.closeSync(); |
416 Expect.throws(() => openedFile.readSync(1), | 416 Expect.throws(() => openedFile.readSync(1), |
417 (e) => e is FileException); | 417 (e) => e is FileSystemException); |
418 done(); | 418 done(); |
419 }); | 419 }); |
420 } | 420 } |
421 | 421 |
422 main() { | 422 main() { |
423 testOpenNonExistent(); | 423 testOpenNonExistent(); |
424 testDeleteNonExistent(); | 424 testDeleteNonExistent(); |
425 testLengthNonExistent(); | 425 testLengthNonExistent(); |
426 testCreateInNonExistentDirectory(); | 426 testCreateInNonExistentDirectory(); |
427 testResolveSymbolicLinksOnNonExistentDirectory(); | 427 testResolveSymbolicLinksOnNonExistentDirectory(); |
428 testReadAsBytesNonExistent(); | 428 testReadAsBytesNonExistent(); |
429 testReadAsTextNonExistent(); | 429 testReadAsTextNonExistent(); |
430 testReadAsLinesNonExistent(); | 430 testReadAsLinesNonExistent(); |
431 testWriteByteToReadOnlyFile(); | 431 testWriteByteToReadOnlyFile(); |
432 testWriteFromToReadOnlyFile(); | 432 testWriteFromToReadOnlyFile(); |
433 testTruncateReadOnlyFile(); | 433 testTruncateReadOnlyFile(); |
434 testOperateOnClosedFile(); | 434 testOperateOnClosedFile(); |
435 testRepeatedlyCloseFile(); | 435 testRepeatedlyCloseFile(); |
436 testRepeatedlyCloseFileSync(); | 436 testRepeatedlyCloseFileSync(); |
437 testReadSyncBigInt(); | 437 testReadSyncBigInt(); |
438 testReadSyncClosedFile(); | 438 testReadSyncClosedFile(); |
439 } | 439 } |
OLD | NEW |