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

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

Issue 23886004: Update dart:io tests to use asyncStart/asyncEnd (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 3 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
OLDNEW
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 import "dart:async"; 5 import "dart:async";
6 import "dart:io";
7
8 import "package:async_helper/async_helper.dart";
6 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
7 import "dart:io";
8 import "dart:isolate";
9 10
10 void testReadInvalidArgs(arg) { 11 void testReadInvalidArgs(arg) {
11 String filename = getFilename("tests/vm/data/fixed_length_file"); 12 String filename = getFilename("tests/vm/data/fixed_length_file");
12 var file = (new File(filename)).openSync(); 13 var file = (new File(filename)).openSync();
13 Expect.throws(() => file.readSync(arg), 14 Expect.throws(() => file.readSync(arg),
14 (e) => e is ArgumentError); 15 (e) => e is ArgumentError);
15 16
16 Expect.throws(() => file.read(arg), 17 Expect.throws(() => file.read(arg),
17 (e) => e is ArgumentError); 18 (e) => e is ArgumentError);
18 } 19 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 Expect.throws(() => ((x, y) => 72 Expect.throws(() => ((x, y) =>
72 FileSystemEntity.typeSync(x, followLinks: y))(".", "why not?")); 73 FileSystemEntity.typeSync(x, followLinks: y))(".", "why not?"));
73 Expect.throws(() => ((x, y) => 74 Expect.throws(() => ((x, y) =>
74 FileSystemEntity.identicalSync(x, y))([1,2,3], ".")); 75 FileSystemEntity.identicalSync(x, y))([1,2,3], "."));
75 Expect.throws(() => ((x, y) => 76 Expect.throws(() => ((x, y) =>
76 FileSystemEntity.identicalSync(x, y))(".", 52)); 77 FileSystemEntity.identicalSync(x, y))(".", 52));
77 Expect.throws(() => ((x) => FileSystemEntity.isLinkSync(x))(52)); 78 Expect.throws(() => ((x) => FileSystemEntity.isLinkSync(x))(52));
78 Expect.throws(() => ((x) => FileSystemEntity.isFileSync(x))(52)); 79 Expect.throws(() => ((x) => FileSystemEntity.isFileSync(x))(52));
79 Expect.throws(() => ((x) => FileSystemEntity.isDirectorySync(x))(52)); 80 Expect.throws(() => ((x) => FileSystemEntity.isDirectorySync(x))(52));
80 81
81 ReceivePort keepAlive = new ReceivePort(); 82 asyncStart();
82 futureThrows(((x) => FileSystemEntity.type(x))([1,2,3])) 83 futureThrows(((x) => FileSystemEntity.type(x))([1,2,3]))
83 .then((_) => futureThrows(((x, y) => 84 .then((_) => futureThrows(((x, y) =>
84 FileSystemEntity.type(x, followLinks: y))(".", "why not?"))) 85 FileSystemEntity.type(x, followLinks: y))(".", "why not?")))
85 .then((_) => futureThrows(((x, y) => 86 .then((_) => futureThrows(((x, y) =>
86 FileSystemEntity.identical(x, y))([1,2,3], "."))) 87 FileSystemEntity.identical(x, y))([1,2,3], ".")))
87 .then((_) => futureThrows(((x, y) => 88 .then((_) => futureThrows(((x, y) =>
88 FileSystemEntity.identical(x, y))(".", 52))) 89 FileSystemEntity.identical(x, y))(".", 52)))
89 .then((_) => futureThrows(((x) => FileSystemEntity.isLink(x))(52))) 90 .then((_) => futureThrows(((x) => FileSystemEntity.isLink(x))(52)))
90 .then((_) => futureThrows(((x) => FileSystemEntity.isFile(x))(52))) 91 .then((_) => futureThrows(((x) => FileSystemEntity.isFile(x))(52)))
91 .then((_) => futureThrows(((x) => FileSystemEntity.isDirectory(x))(52))) 92 .then((_) => futureThrows(((x) => FileSystemEntity.isDirectory(x))(52)))
92 .then((_) => keepAlive.close()); 93 .then((_) => asyncEnd());
93 } 94 }
94 95
95 String getFilename(String path) { 96 String getFilename(String path) {
96 return new File(path).existsSync() ? path : 'runtime/$path'; 97 return new File(path).existsSync() ? path : 'runtime/$path';
97 } 98 }
98 99
99 main() { 100 main() {
100 testReadInvalidArgs('asdf'); 101 testReadInvalidArgs('asdf');
101 testReadIntoInvalidArgs(12, 0, 1); 102 testReadIntoInvalidArgs(12, 0, 1);
102 testReadIntoInvalidArgs(new List(10), '0', 1); 103 testReadIntoInvalidArgs(new List(10), '0', 1);
103 testReadIntoInvalidArgs(new List(10), 0, '1'); 104 testReadIntoInvalidArgs(new List(10), 0, '1');
104 testWriteByteInvalidArgs('asdf'); 105 testWriteByteInvalidArgs('asdf');
105 testWriteFromInvalidArgs(12, 0, 1); 106 testWriteFromInvalidArgs(12, 0, 1);
106 testWriteFromInvalidArgs(new List(10), '0', 1); 107 testWriteFromInvalidArgs(new List(10), '0', 1);
107 testWriteFromInvalidArgs(new List(10), 0, '1'); 108 testWriteFromInvalidArgs(new List(10), 0, '1');
108 testWriteStringInvalidArgs("Hello, world", 42); 109 testWriteStringInvalidArgs("Hello, world", 42);
109 testFileSystemEntity(); 110 testFileSystemEntity();
110 } 111 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_input_stream_test.dart ('k') | tests/standalone/io/file_non_ascii_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698