| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 | 
|  | 3 // BSD-style license that can be found in the LICENSE file. | 
|  | 4 | 
|  | 5 // 'fuzz' test the file APIs by providing unexpected type arguments. The test | 
|  | 6 // passes if the VM does not crash. | 
|  | 7 | 
|  | 8 #import('dart:io'); | 
|  | 9 | 
|  | 10 final typeMapping = const { | 
|  | 11   'int': 0, | 
|  | 12   'String': 'a', | 
|  | 13   'FileMode': FileMode.READ, | 
|  | 14   'num': 0.50, | 
|  | 15   'List<int>': const [1, 2, 3] | 
|  | 16 }; | 
|  | 17 | 
|  | 18 doItSync(Function f) { | 
|  | 19   // Ignore all exceptions. | 
|  | 20   try { f(); } catch (var e) {} | 
|  | 21 } | 
|  | 22 | 
|  | 23 fuzzSyncMethods() { | 
|  | 24   typeMapping.forEach((k, v) { | 
|  | 25     doItSync(() { | 
|  | 26       var f = new File(v); | 
|  | 27       doItSync(f.existsSync); | 
|  | 28       doItSync(f.createSync); | 
|  | 29       doItSync(f.deleteSync); | 
|  | 30       doItSync(f.directorySync); | 
|  | 31       doItSync(f.lengthSync); | 
|  | 32       doItSync(f.fullPathSync); | 
|  | 33       doItSync(() => f.openInputStream().onError = (e) => null); | 
|  | 34       doItSync(f.readAsBytesSync); | 
|  | 35       typeMapping.forEach((k2, v2) { | 
|  | 36         doItSync(() => f.openSync(v2)); | 
|  | 37         doItSync(() => f.openOutputStream(v2).onError = (e) => null); | 
|  | 38         doItSync(() => f.readAsTextSync(v2)); | 
|  | 39         doItSync(() => f.readAsLinesSync(v2)); | 
|  | 40       }); | 
|  | 41     }); | 
|  | 42   }); | 
|  | 43 } | 
|  | 44 | 
|  | 45 main() { | 
|  | 46   fuzzSyncMethods(); | 
|  | 47 } | 
| OLD | NEW | 
|---|