OLD | NEW |
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:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 futures.add(doItAsync(d.create)); | 44 futures.add(doItAsync(d.create)); |
45 futures.add(doItAsync(d.delete)); | 45 futures.add(doItAsync(d.delete)); |
46 futures.add(doItAsync(() { | 46 futures.add(doItAsync(() { |
47 return d.createTemp().then((temp) { | 47 return d.createTemp().then((temp) { |
48 return temp.delete(); | 48 return temp.delete(); |
49 }); | 49 }); |
50 })); | 50 })); |
51 futures.add(doItAsync(() { | 51 futures.add(doItAsync(() { |
52 return d.exists().then((res) { | 52 return d.exists().then((res) { |
53 if (!res) return d.delete(recursive: true); | 53 if (!res) return d.delete(recursive: true); |
54 return new Future.immediate(true); | 54 return new Future.value(true); |
55 }); | 55 }); |
56 })); | 56 })); |
57 typeMapping.forEach((k2, v2) { | 57 typeMapping.forEach((k2, v2) { |
58 futures.add(doItAsync(() => d.rename(v2))); | 58 futures.add(doItAsync(() => d.rename(v2))); |
59 futures.add(doItAsync(() { | 59 futures.add(doItAsync(() { |
60 d.list(recursive: v2).listen((_) {}, onError: (e) => null); | 60 d.list(recursive: v2).listen((_) {}, onError: (e) => null); |
61 })); | 61 })); |
62 }); | 62 }); |
63 }); | 63 }); |
64 Future.wait(futures).then((ignore) => port.close()); | 64 Future.wait(futures).then((ignore) => port.close()); |
65 } | 65 } |
66 | 66 |
67 main() { | 67 main() { |
68 fuzzSyncMethods(); | 68 fuzzSyncMethods(); |
69 fuzzAsyncMethods(); | 69 fuzzAsyncMethods(); |
70 } | 70 } |
OLD | NEW |