Chromium Code Reviews| 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) { |