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

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: 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
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..94330279ad56fa0d91a115f0cfce197640fe54f7 100644
--- a/tests/standalone/io/file_invalid_arguments_test.dart
+++ b/tests/standalone/io/file_invalid_arguments_test.dart
@@ -8,127 +8,97 @@ 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'));
+ Expect.isTrue(e is ArgumentError);
+ Expect.isTrue(e.toString().contains(arg.toString()));
}
var errors = 0;
Bill Hesse 2013/06/27 16:32:46 Remove the unused errors var.
Anders Johnsen 2013/06/27 16:42:19 Done.
- 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();
- });
- });
+ try {
+ var readFuture = file.read(arg);
+ } catch (e) {
+ Expect.isTrue(e is ArgumentError);
+ Expect.isTrue(e.toString().contains(arg.toString()));
+ }
}
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'));
+ Expect.isTrue(e is ArgumentError);
}
- var errors = 0;
- var readIntoFuture = file.readInto(buffer, start, end);
- readIntoFuture.then((bytes) {
+ try {
+ file.readInto(buffer, start, end);
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();
- });
- });
+ } catch (e) {
+ Expect.isTrue(e is ArgumentError);
Bill Hesse 2013/06/27 16:32:46 Why not Expect.throws(() => file.readInto(buffer,
Anders Johnsen 2013/06/27 16:42:19 Done.
+ }
}
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'));
+ Expect.isTrue(e is ArgumentError);
+ Expect.isTrue(e.toString().contains(value.toString()));
}
- var writeByteFuture = file.writeByte(value);
- writeByteFuture.then((ignore) {
+ try {
+ file.writeByte(value);
Expect.fail('exception expected');
- }).catchError((error) {
- Expect.isTrue(error is FileException);
- Expect.isTrue(error.toString().contains('Invalid argument'));
- file.close().then((ignore) {
- port.close();
- });
- });
+ } catch (e) {
+ Expect.isTrue(e is ArgumentError);
+ Expect.isTrue(e.toString().contains(value.toString()));
+ }
Bill Hesse 2013/06/27 16:32:46 Expect.throws?
Anders Johnsen 2013/06/27 16:42:19 Done.
}
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'));
+ Expect.isTrue(e is ArgumentError);
}
- var writeFromFuture = file.writeFrom(buffer, start, end);
- writeFromFuture.then((ignore) {
+ try {
+ file.writeFrom(buffer, start, end);
Expect.fail('exception expected');
- }).catchError((error) {
- Expect.isTrue(error is FileException);
- Expect.isTrue(error.toString().contains('Invalid arguments'));
- file.close().then((ignore) {
- port.close();
- });
- });
+ } catch (e) {
+ Expect.isTrue(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);
+ Expect.isTrue(e is ArgumentError);
}
- var writeStringFuture = file.writeString(string, encoding: encoding);
- writeStringFuture.then((ignore) {
+ try {
+ file.writeString(string, encoding: encoding);
Expect.fail('exception expected');
- }).catchError((error) {
- Expect.isTrue(error is FileException);
- file.close().then((ignore) {
- port.close();
- });
- });
+ } catch (e) {
+ Expect.isTrue(e is ArgumentError);
+ }
}
Future futureThrows(Future result) {
« tests/standalone/io/file_error_test.dart ('K') | « tests/standalone/io/file_error_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698