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

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

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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 | « tests/standalone/io/directory_fuzz_test.dart ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import "dart:io"; 5 import "dart:io";
6 import "dart:isolate";
6 7
7 class DirectoryInvalidArgumentsTest { 8 void testFailingList(Directory d, var recursive) {
8 static void testFailingList(Directory d, var recursive) { 9 var port = new ReceivePort();
9 int errors = 0; 10 int errors = 0;
10 var lister = d.list(recursive: recursive); 11 d.list(recursive: recursive).listen(
11 lister.onError = (error) { 12 () => Expect.fail("Unexpected listing result"),
13 onError: (error) {
12 errors += 1; 14 errors += 1;
13 }; 15 },
14 lister.onDone = (completed) { 16 onDone: () {
17 port.close();
15 Expect.equals(1, errors); 18 Expect.equals(1, errors);
16 Expect.isFalse(completed); 19 });
17 }; 20 Expect.equals(0, errors);
18 Expect.equals(0, errors); 21 }
22
23 void testInvalidArguments() {
24 Directory d = new Directory(12);
25 try {
26 d.existsSync();
27 Expect.fail("No exception thrown");
28 } catch (e) {
29 Expect.isTrue(e is ArgumentError);
19 } 30 }
20 31 try {
21 static void testInvalidArguments() { 32 d.deleteSync();
22 Directory d = new Directory(12); 33 Expect.fail("No exception thrown");
23 try { 34 } catch (e) {
24 d.existsSync(); 35 Expect.isTrue(e is ArgumentError);
25 Expect.fail("No exception thrown");
26 } catch (e) {
27 Expect.isTrue(e is ArgumentError);
28 }
29 try {
30 d.deleteSync();
31 Expect.fail("No exception thrown");
32 } catch (e) {
33 Expect.isTrue(e is ArgumentError);
34 }
35 try {
36 d.createSync();
37 Expect.fail("No exception thrown");
38 } catch (e) {
39 Expect.isTrue(e is ArgumentError);
40 }
41 testFailingList(d, false);
42 Expect.throws(() => d.listSync(recursive: true),
43 (e) => e is ArgumentError);
44 d = new Directory(".");
45 testFailingList(d, 1);
46 Expect.throws(() => d.listSync(recursive: 1),
47 (e) => e is ArgumentError);
48 } 36 }
49 37 try {
50 static void testMain() { 38 d.createSync();
51 testInvalidArguments(); 39 Expect.fail("No exception thrown");
40 } catch (e) {
41 Expect.isTrue(e is ArgumentError);
52 } 42 }
43 testFailingList(d, false);
44 Expect.throws(() => d.listSync(recursive: true),
45 (e) => e is ArgumentError);
46 d = new Directory(".");
47 testFailingList(d, 1);
48 Expect.throws(() => d.listSync(recursive: 1),
49 (e) => e is ArgumentError);
53 } 50 }
54 51
55 main() { 52 main() {
56 DirectoryInvalidArgumentsTest.testMain(); 53 testInvalidArguments();
57 } 54 }
OLDNEW
« no previous file with comments | « tests/standalone/io/directory_fuzz_test.dart ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698