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

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

Issue 14907002: dart:io | Implement asynchronous versions of FileSystemEntity methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add implementation of FileSystemEntity.type, and refactor error handling. Created 7 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 | « sdk/lib/io/file_system_entity.dart ('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
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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "dart:io"; 6 import "dart:io";
7 import "dart:isolate"; 7 import "dart:isolate";
8 8
9 void testReadInvalidArgs(arg) { 9 void testReadInvalidArgs(arg) {
10 var port = new ReceivePort(); 10 var port = new ReceivePort();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 writeStringFuture.then((ignore) { 123 writeStringFuture.then((ignore) {
124 Expect.fail('exception expected'); 124 Expect.fail('exception expected');
125 }).catchError((error) { 125 }).catchError((error) {
126 Expect.isTrue(error is FileIOException); 126 Expect.isTrue(error is FileIOException);
127 file.close().then((ignore) { 127 file.close().then((ignore) {
128 port.close(); 128 port.close();
129 }); 129 });
130 }); 130 });
131 } 131 }
132 132
133 Future futureThrows(Future result) {
134 return result.then((value) {
135 throw new ExpectException(
136 "futureThrows received $value instead of an exception");
137 },
138 onError: (_) => null
139 );
140 }
141
142 void testFileSystemEntity() {
143 Expect.throws(() => FileSystemEntity.typeSync([1,2,3]));
144 Expect.throws(() =>
145 FileSystemEntity.typeSync(".", followLinks: "why not?"));
146 Expect.throws(() => FileSystemEntity.identicalSync([1,2,3], "."));
147 Expect.throws(() => FileSystemEntity.identicalSync("."));
148 Expect.throws(() => FileSystemEntity.identicalSync(".", 52));
149 Expect.throws(() => FileSystemEntity.isLinkSync(52));
150 Expect.throws(() => FileSystemEntity.isFileSync(52));
151 Expect.throws(() => FileSystemEntity.isDirectorySync(52));
152
153 ReceivePort keepAlive = new ReceivePort();
154 futureThrows(FileSystemEntity.type([1,2,3]))
155 .then((_) => futureThrows(
156 FileSystemEntity.type(".", followLinks: "why not?")))
157 .then((_) => futureThrows(FileSystemEntity.identical([1,2,3], ".")))
158 .then((_) => Expect.throws(() =>FileSystemEntity.identical(".")))
159 .then((_) => futureThrows(FileSystemEntity.identical(".", 52)))
160 .then((_) => futureThrows(FileSystemEntity.isLink(52)))
161 .then((_) => futureThrows(FileSystemEntity.isFile(52)))
162 .then((_) => futureThrows(FileSystemEntity.isDirectory(52)))
163 .then((_) => keepAlive.close());
164 }
165
133 String getFilename(String path) { 166 String getFilename(String path) {
134 return new File(path).existsSync() ? path : 'runtime/$path'; 167 return new File(path).existsSync() ? path : 'runtime/$path';
135 } 168 }
136 169
137 main() { 170 main() {
138 testReadInvalidArgs('asdf'); 171 testReadInvalidArgs('asdf');
139 testReadIntoInvalidArgs(12, 0, 1); 172 testReadIntoInvalidArgs(12, 0, 1);
140 testReadIntoInvalidArgs(new List(10), '0', 1); 173 testReadIntoInvalidArgs(new List(10), '0', 1);
141 testReadIntoInvalidArgs(new List(10), 0, '1'); 174 testReadIntoInvalidArgs(new List(10), 0, '1');
142 testWriteByteInvalidArgs('asdf'); 175 testWriteByteInvalidArgs('asdf');
143 testWriteFromInvalidArgs(12, 0, 1); 176 testWriteFromInvalidArgs(12, 0, 1);
144 testWriteFromInvalidArgs(new List(10), '0', 1); 177 testWriteFromInvalidArgs(new List(10), '0', 1);
145 testWriteFromInvalidArgs(new List(10), 0, '1'); 178 testWriteFromInvalidArgs(new List(10), 0, '1');
146 testWriteStringInvalidArgs("Hello, world", 42); 179 testWriteStringInvalidArgs("Hello, world", 42);
180 testFileSystemEntity();
147 } 181 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file_system_entity.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698