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

Unified Diff: tests/standalone/io/file_invalid_arguments_test.dart

Issue 18090003: Add FileException.path and clean up file exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: CLean up test and remove debug code. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/link.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/file_invalid_arguments_test.dart
diff --git a/tests/standalone/io/file_invalid_arguments_test.dart b/tests/standalone/io/file_invalid_arguments_test.dart
index 3ae9a9cbb537462bd5db507222bc9405124e8143..846e88222e4d08a6d38284cb2e2709d1a9d44308 100644
--- a/tests/standalone/io/file_invalid_arguments_test.dart
+++ b/tests/standalone/io/file_invalid_arguments_test.dart
@@ -8,127 +8,53 @@ import "dart:io";
import "dart:isolate";
void testReadInvalidArgs(arg) {
- var port = new ReceivePort();
String filename = getFilename("tests/vm/data/fixed_length_file");
var file = (new File(filename)).openSync();
- try {
- file.readSync(arg);
- Expect.fail('exception expected');
- } catch (e) {
- Expect.isTrue(e is FileException);
- Expect.isTrue(e.toString().contains('Invalid arguments'));
- }
-
- var errors = 0;
- var readFuture = file.read(arg);
- readFuture.then((bytes) {
- Expect.fail('exception expected');
- }).catchError((error) {
- errors++;
- Expect.isTrue(error is FileException);
- Expect.isTrue(error.toString().contains('Invalid arguments'));
- file.close().then((ignore) {
- Expect.equals(1, errors);
- port.close();
- });
- });
+ Expect.throws(() => file.readSync(arg),
+ (e) => e is ArgumentError);
+
+ Expect.throws(() => file.read(arg),
+ (e) => e is ArgumentError);
}
void testReadIntoInvalidArgs(buffer, start, end) {
- var port = new ReceivePort();
String filename = getFilename("tests/vm/data/fixed_length_file");
var file = (new File(filename)).openSync();
- try {
- file.readIntoSync(buffer, start, end);
- Expect.fail('exception expected');
- } catch (e) {
- Expect.isTrue(e is FileException);
- Expect.isTrue(e.toString().contains('Invalid arguments'));
- }
-
- var errors = 0;
- var readIntoFuture = file.readInto(buffer, start, end);
- readIntoFuture.then((bytes) {
- Expect.fail('exception expected');
- }).catchError((error) {
- errors++;
- Expect.isTrue(error is FileException);
- Expect.isTrue(error.toString().contains('Invalid arguments'));
- file.close().then((ignore) {
- Expect.equals(1, errors);
- port.close();
- });
- });
+ Expect.throws(() => file.readIntoSync(buffer, start, end),
+ (e) => e is ArgumentError);
+
+ Expect.throws(() => file.readInto(buffer, start, end),
+ (e) => e is ArgumentError);
}
void testWriteByteInvalidArgs(value) {
- var port = new ReceivePort();
String filename = getFilename("tests/vm/data/fixed_length_file");
var file = (new File("${filename}_out")).openSync(mode: FileMode.WRITE);
- try {
- file.writeByteSync(value);
- Expect.fail('exception expected');
- } catch (e) {
- Expect.isTrue(e is FileException);
- Expect.isTrue(e.toString().contains('Invalid argument'));
- }
-
- var writeByteFuture = file.writeByte(value);
- writeByteFuture.then((ignore) {
- Expect.fail('exception expected');
- }).catchError((error) {
- Expect.isTrue(error is FileException);
- Expect.isTrue(error.toString().contains('Invalid argument'));
- file.close().then((ignore) {
- port.close();
- });
- });
+ Expect.throws(() => file.writeByteSync(value),
+ (e) => e is ArgumentError);
+
+ Expect.throws(() => file.writeByte(value),
+ (e) => e is ArgumentError);
}
void testWriteFromInvalidArgs(buffer, start, end) {
- var port = new ReceivePort();
String filename = getFilename("tests/vm/data/fixed_length_file");
var file = (new File("${filename}_out")).openSync(mode: FileMode.WRITE);
- try {
- file.writeFromSync(buffer, start, end);
- Expect.fail('exception expected');
- } catch (e) {
- Expect.isTrue(e is FileException);
- Expect.isTrue(e.toString().contains('Invalid arguments'));
- }
-
- var writeFromFuture = file.writeFrom(buffer, start, end);
- writeFromFuture.then((ignore) {
- Expect.fail('exception expected');
- }).catchError((error) {
- Expect.isTrue(error is FileException);
- Expect.isTrue(error.toString().contains('Invalid arguments'));
- file.close().then((ignore) {
- port.close();
- });
- });
+ Expect.throws(() => file.writeFromSync(buffer, start, end),
+ (e) => e is ArgumentError);
+
+ Expect.throws(() => file.writeFrom(buffer, start, end),
+ (e) => e is ArgumentError);
}
void testWriteStringInvalidArgs(string, encoding) {
- var port = new ReceivePort();
String filename = getFilename("tests/vm/data/fixed_length_file");
var file = new File("${filename}_out").openSync(mode: FileMode.WRITE);
- try {
- file.writeStringSync(string, encoding: encoding);
- Expect.fail('exception expected');
- } catch (e) {
- Expect.isTrue(e is FileException);
- }
-
- var writeStringFuture = file.writeString(string, encoding: encoding);
- writeStringFuture.then((ignore) {
- Expect.fail('exception expected');
- }).catchError((error) {
- Expect.isTrue(error is FileException);
- file.close().then((ignore) {
- port.close();
- });
- });
+ Expect.throws(() => file.writeStringSync(string, encoding: encoding),
+ (e) => e is ArgumentError);
+
+ Expect.throws(() => file.writeString(string, encoding: encoding),
+ (e) => e is ArgumentError);
}
Future futureThrows(Future result) {
« no previous file with comments | « sdk/lib/io/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698