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 file APIs by providing unexpected type arguments. The test | 5 // 'fuzz' test the file APIs by providing unexpected type arguments. The test |
6 // passes if the VM does not crash. | 6 // 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'; |
11 | 11 |
12 import 'fuzz_support.dart'; | 12 import 'fuzz_support.dart'; |
13 | 13 |
14 fuzzSyncMethods() { | 14 fuzzSyncMethods() { |
15 typeMapping.forEach((k, v) { | 15 typeMapping.forEach((k, v) { |
16 doItSync(() { | 16 doItSync(() { |
17 var f = new File(v); | 17 var f = new File(v); |
18 doItSync(f.existsSync); | 18 doItSync(f.existsSync); |
19 doItSync(f.createSync); | 19 doItSync(f.createSync); |
20 doItSync(f.deleteSync); | 20 doItSync(f.deleteSync); |
21 doItSync(f.directorySync); | 21 doItSync(f.directorySync); |
22 doItSync(f.lengthSync); | 22 doItSync(f.lengthSync); |
23 doItSync(f.modifiedSync); | 23 doItSync(f.modifiedSync); |
24 doItSync(f.fullPathSync); | 24 doItSync(f.fullPathSync); |
25 doItSync(() => f.openInputStream().onError = (e) => null); | 25 doItSync(() => f.openRead().listen(() {}, onError: (e) {})); |
26 doItSync(f.readAsBytesSync); | 26 doItSync(f.readAsBytesSync); |
27 doItSync(f.readAsStringSync); | 27 doItSync(f.readAsStringSync); |
28 doItSync(f.readAsLinesSync); | 28 doItSync(f.readAsLinesSync); |
29 typeMapping.forEach((k2, v2) { | 29 typeMapping.forEach((k2, v2) { |
30 doItSync(() => f.openSync(v2)); | 30 doItSync(() => f.openSync(v2)); |
31 doItSync(() => f.openOutputStream(v2).onError = (e) => null); | 31 doItSync(() => f.openWrite(v2)); |
32 doItSync(() => f.readAsStringSync(v2)); | 32 doItSync(() => f.readAsStringSync(v2)); |
33 doItSync(() => f.readAsLinesSync(v2)); | 33 doItSync(() => f.readAsLinesSync(v2)); |
34 }); | 34 }); |
35 }); | 35 }); |
36 }); | 36 }); |
37 } | 37 } |
38 | 38 |
39 fuzzAsyncMethods() { | 39 fuzzAsyncMethods() { |
40 var port = new ReceivePort(); | 40 var port = new ReceivePort(); |
41 var futures = []; | 41 var futures = []; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 temp.deleteSync(recursive: true); | 119 temp.deleteSync(recursive: true); |
120 }); | 120 }); |
121 } | 121 } |
122 | 122 |
123 main() { | 123 main() { |
124 fuzzSyncMethods(); | 124 fuzzSyncMethods(); |
125 fuzzAsyncMethods(); | 125 fuzzAsyncMethods(); |
126 fuzzSyncRandomAccessMethods(); | 126 fuzzSyncRandomAccessMethods(); |
127 fuzzAsyncRandomAccessMethods(); | 127 fuzzAsyncRandomAccessMethods(); |
128 } | 128 } |
OLD | NEW |