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

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

Issue 12609004: Change all File APIs to make the mode and encoding arguments named (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments and changed other use places Created 7 years, 9 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 | « tests/standalone/io/file_input_stream_test.dart ('k') | tests/standalone/io/file_test.dart » ('j') | 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 b4c1720bd659bab0958cfaaaa9629c67d6d636b7..515271cc3096f11e24ae3e3d133d45b64f87c475 100644
--- a/tests/standalone/io/file_invalid_arguments_test.dart
+++ b/tests/standalone/io/file_invalid_arguments_test.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -62,7 +62,7 @@ void testReadListInvalidArgs(buffer, offset, length) {
void testWriteByteInvalidArgs(value) {
var port = new ReceivePort();
String filename = getFilename("tests/vm/data/fixed_length_file");
- var file = (new File("${filename}_out")).openSync(FileMode.WRITE);
+ var file = (new File("${filename}_out")).openSync(mode: FileMode.WRITE);
try {
file.writeByteSync(value);
Expect.fail('exception expected');
@@ -86,7 +86,7 @@ void testWriteByteInvalidArgs(value) {
void testWriteListInvalidArgs(buffer, offset, bytes) {
var port = new ReceivePort();
String filename = getFilename("tests/vm/data/fixed_length_file");
- var file = (new File("${filename}_out")).openSync(FileMode.WRITE);
+ var file = (new File("${filename}_out")).openSync(mode: FileMode.WRITE);
try {
file.writeListSync(buffer, offset, bytes);
Expect.fail('exception expected');
@@ -107,34 +107,26 @@ void testWriteListInvalidArgs(buffer, offset, bytes) {
});
}
-void testWriteStringInvalidArgs(string) {
+void testWriteStringInvalidArgs(string, encoding) {
var port = new ReceivePort();
String filename = getFilename("tests/vm/data/fixed_length_file");
- var file = new File("${filename}_out");
- file.openSync(FileMode.WRITE);
+ var file = new File("${filename}_out").openSync(mode: FileMode.WRITE);
try {
- file.writeString(string);
+ file.writeStringSync(string, encoding: encoding);
Expect.fail('exception expected');
} catch (e) {
Expect.isTrue(e is FileIOException);
- Expect.isTrue(e.toString().contains('writeString failed'));
}
- var errors = 0;
- file.onError = (s) {
- errors++;
- Expect.isTrue(s.contains('writeString failed'));
- };
- var calls = 0;
- file.onNoPendingWrites = () {
- if (++calls > 1) Expect.fail('write list invalid argument');
- };
- file.writeString(string);
- file.onClosed = () {
- Expect.equals(1, errors);
- port.close();
- };
- file.close();
+ var writeStringFuture = file.writeString(string, encoding: encoding);
+ writeStringFuture.then((ignore) {
+ Expect.fail('exception expected');
+ }).catchError((s) {
+ Expect.isTrue(s.error is FileIOException);
+ file.close().then((ignore) {
+ port.close();
+ });
+ });
}
String getFilename(String path) {
@@ -150,4 +142,5 @@ main() {
testWriteListInvalidArgs(12, 0, 1);
testWriteListInvalidArgs(new List(10), '0', 1);
testWriteListInvalidArgs(new List(10), 0, '1');
+ testWriteStringInvalidArgs("Hello, world", 42);
}
« no previous file with comments | « tests/standalone/io/file_input_stream_test.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698