| 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 // '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 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 for (var p in typePermutations(3)) { | 81 for (var p in typePermutations(3)) { |
| 82 doItSync(() => opened.readIntoSync(p[0], p[1], p[2])); | 82 doItSync(() => opened.readIntoSync(p[0], p[1], p[2])); |
| 83 doItSync(() => opened.writeFromSync(p[0], p[1], p[2])); | 83 doItSync(() => opened.writeFromSync(p[0], p[1], p[2])); |
| 84 } | 84 } |
| 85 opened.closeSync(); | 85 opened.closeSync(); |
| 86 } | 86 } |
| 87 temp.deleteSync(recursive: true); | 87 temp.deleteSync(recursive: true); |
| 88 } | 88 } |
| 89 | 89 |
| 90 fuzzAsyncRandomAccessMethods() { | 90 fuzzAsyncRandomAccessMethods() { |
| 91 var d = new Directory(''); | |
| 92 var temp = Directory.systemTemp.createTempSync('dart_file_fuzz'); | 91 var temp = Directory.systemTemp.createTempSync('dart_file_fuzz'); |
| 93 var file = new File('${temp.path}/x'); | 92 var file = new File('${temp.path}/x'); |
| 94 file.createSync(); | 93 file.createSync(); |
| 95 var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ]; | 94 var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ]; |
| 96 var futures = []; | 95 var futures = []; |
| 97 var openedFiles = []; | 96 var openedFiles = []; |
| 98 for (var m in modes) { | 97 for (var m in modes) { |
| 99 var opened = file.openSync(mode: m); | 98 var opened = file.openSync(mode: m); |
| 100 openedFiles.add(opened); | 99 openedFiles.add(opened); |
| 101 typeMapping.forEach((k, v) { | 100 typeMapping.forEach((k, v) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 118 temp.deleteSync(recursive: true); | 117 temp.deleteSync(recursive: true); |
| 119 }); | 118 }); |
| 120 } | 119 } |
| 121 | 120 |
| 122 main() { | 121 main() { |
| 123 fuzzSyncMethods(); | 122 fuzzSyncMethods(); |
| 124 fuzzAsyncMethods(); | 123 fuzzAsyncMethods(); |
| 125 fuzzSyncRandomAccessMethods(); | 124 fuzzSyncRandomAccessMethods(); |
| 126 fuzzAsyncRandomAccessMethods(); | 125 fuzzAsyncRandomAccessMethods(); |
| 127 } | 126 } |
| OLD | NEW |