Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: tests/standalone/io/file_fuzz_test.dart

Issue 10383179: Start 'fuzzing' of dart:io APIs and fix first issue found. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698