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

Side by Side Diff: tests/standalone/io/directory_fuzz_test.dart

Issue 11748017: Add synchronous directory listing to dart:io Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Avoid memory leak of DirectorySyncLister. Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // 'fuzz' test the directory APIs by providing unexpected type 5 // 'fuzz' test the directory APIs by providing unexpected type
6 // arguments. The test passes if the VM does not crash. 6 // arguments. The test passes if the VM does not crash.
7 7
8 import "dart:io"; 8 import "dart:io";
9 import "dart:isolate"; 9 import "dart:isolate";
10 10
11 import "fuzz_support.dart"; 11 import "fuzz_support.dart";
12 12
13 fuzzSyncMethods() { 13 fuzzSyncMethods() {
14 typeMapping.forEach((k, v) { 14 typeMapping.forEach((k, v) {
15 doItSync(() { 15 doItSync(() {
16 var d = new Directory(v); 16 var d = new Directory(v);
17 doItSync(d.existsSync); 17 doItSync(d.existsSync);
18 doItSync(d.createSync); 18 doItSync(d.createSync);
19 doItSync(d.deleteSync); 19 doItSync(d.deleteSync);
20 doItSync(d.listSync);
20 doItSync(() { 21 doItSync(() {
21 d.createTempSync().deleteSync(); 22 d.createTempSync().deleteSync();
22 }); 23 });
23 doItSync(() { 24 doItSync(() {
24 // Let's be a little careful. If the directory exists we don't 25 // Let's be a little careful. If the directory exists we don't
25 // want to delete it and all its contents. 26 // want to delete it and all its contents.
26 if (!d.existsSync()) d.deleteSync(recursive: true); 27 if (!d.existsSync()) d.deleteSync(recursive: true);
27 }); 28 });
28 typeMapping.forEach((k2, v2) { 29 typeMapping.forEach((k2, v2) {
29 doItSync(() => d.renameSync(v2)); 30 doItSync(() => d.renameSync(v2));
31 doItSync(() => d.listSync(recursive: v2));
30 doItSync(() => d.list(recursive: v2).onError = (e) => null); 32 doItSync(() => d.list(recursive: v2).onError = (e) => null);
31 }); 33 });
32 }); 34 });
33 }); 35 });
34 } 36 }
35 37
36 fuzzAsyncMethods() { 38 fuzzAsyncMethods() {
37 var port = new ReceivePort(); 39 var port = new ReceivePort();
38 var futures = []; 40 var futures = [];
39 typeMapping.forEach((k, v) { 41 typeMapping.forEach((k, v) {
(...skipping 16 matching lines...) Expand all
56 futures.add(doItAsync(() => d.rename(v2))); 58 futures.add(doItAsync(() => d.rename(v2)));
57 }); 59 });
58 }); 60 });
59 Futures.wait(futures).then((ignore) => port.close()); 61 Futures.wait(futures).then((ignore) => port.close());
60 } 62 }
61 63
62 main() { 64 main() {
63 fuzzSyncMethods(); 65 fuzzSyncMethods();
64 fuzzAsyncMethods(); 66 fuzzAsyncMethods();
65 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698