| 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:io'); | 8 #import('dart:io'); |
| 9 #import('dart:isolate'); | 9 #import('dart:isolate'); |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 }); | 77 }); |
| 78 for (var p in typePermutations(2)) { | 78 for (var p in typePermutations(2)) { |
| 79 doItSync(() => opened.writeStringSync(p[0], p[1])); | 79 doItSync(() => opened.writeStringSync(p[0], p[1])); |
| 80 } | 80 } |
| 81 for (var p in typePermutations(3)) { | 81 for (var p in typePermutations(3)) { |
| 82 doItSync(() => opened.readListSync(p[0], p[1], p[2])); | 82 doItSync(() => opened.readListSync(p[0], p[1], p[2])); |
| 83 doItSync(() => opened.writeListSync(p[0], p[1], p[2])); | 83 doItSync(() => opened.writeListSync(p[0], p[1], p[2])); |
| 84 } | 84 } |
| 85 opened.closeSync(); | 85 opened.closeSync(); |
| 86 } | 86 } |
| 87 temp.deleteRecursivelySync(); | 87 temp.deleteSync(recursive: true); |
| 88 } | 88 } |
| 89 | 89 |
| 90 fuzzAsyncRandomAccessMethods() { | 90 fuzzAsyncRandomAccessMethods() { |
| 91 var d = new Directory(''); | 91 var d = new Directory(''); |
| 92 var temp = d.createTempSync(); | 92 var temp = d.createTempSync(); |
| 93 var file = new File('${temp.path}/x'); | 93 var file = new File('${temp.path}/x'); |
| 94 file.createSync(); | 94 file.createSync(); |
| 95 var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ]; | 95 var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ]; |
| 96 var futures = []; | 96 var futures = []; |
| 97 var openedFiles = []; | 97 var openedFiles = []; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 108 } | 108 } |
| 109 for (var p in typePermutations(3)) { | 109 for (var p in typePermutations(3)) { |
| 110 futures.add(doItAsync(() => opened.readList(p[0], p[1], p[2]))); | 110 futures.add(doItAsync(() => opened.readList(p[0], p[1], p[2]))); |
| 111 futures.add(doItAsync(() => opened.writeList(p[0], p[1], p[2]))); | 111 futures.add(doItAsync(() => opened.writeList(p[0], p[1], p[2]))); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 Futures.wait(futures).then((ignore) { | 114 Futures.wait(futures).then((ignore) { |
| 115 for (var opened in openedFiles) { | 115 for (var opened in openedFiles) { |
| 116 opened.closeSync(); | 116 opened.closeSync(); |
| 117 } | 117 } |
| 118 temp.deleteRecursivelySync(); | 118 temp.deleteSync(recursive: true); |
| 119 }); | 119 }); |
| 120 } | 120 } |
| 121 | 121 |
| 122 main() { | 122 main() { |
| 123 fuzzSyncMethods(); | 123 fuzzSyncMethods(); |
| 124 fuzzAsyncMethods(); | 124 fuzzAsyncMethods(); |
| 125 fuzzSyncRandomAccessMethods(); | 125 fuzzSyncRandomAccessMethods(); |
| 126 fuzzAsyncRandomAccessMethods(); | 126 fuzzAsyncRandomAccessMethods(); |
| 127 } | 127 } |
| OLD | NEW |