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

Side by Side Diff: tests/standalone/src/FileInvalidArgumentsTest.dart

Issue 9474004: Make FileInputStream and FileOutputStream actually asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove accidental edit Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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("dart:io"); 5 #import("dart:io");
6 6
7 class FileTest { 7 class FileTest {
8 static void testOpenInvalidArgs(name, [writable = false]) { 8 static void testOpenInvalidArgs(name, [writable = false]) {
9 var file = new File(name); 9 var file = new File(name);
10 try { 10 try {
11 file.openSync(); 11 file.openSync();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } catch (var e) { 97 } catch (var e) {
98 Expect.isTrue(e is FileIOException); 98 Expect.isTrue(e is FileIOException);
99 Expect.isTrue(e.toString().contains('Invalid argument')); 99 Expect.isTrue(e.toString().contains('Invalid argument'));
100 } 100 }
101 101
102 var errors = 0; 102 var errors = 0;
103 file.errorHandler = (s) { 103 file.errorHandler = (s) {
104 errors++; 104 errors++;
105 Expect.isTrue(s.contains('Invalid argument')); 105 Expect.isTrue(s.contains('Invalid argument'));
106 }; 106 };
107 file.noPendingWriteHandler = (bytes) { 107 var calls = 0;
108 Expect.fail('write list invalid argument'); 108 file.noPendingWriteHandler = () {
109 if (++calls > 1) Expect.fail('write list invalid argument');
109 }; 110 };
110 file.writeByte(value); 111 file.writeByte(value);
111 file.closeHandler = () { 112 file.closeHandler = () {
112 Expect.equals(1, errors); 113 Expect.equals(1, errors);
113 }; 114 };
114 file.close(); 115 file.close();
115 } 116 }
116 117
117 static void testWriteListInvalidArgs(buffer, offset, bytes) { 118 static void testWriteListInvalidArgs(buffer, offset, bytes) {
118 String filename = getFilename("tests/vm/data/fixed_length_file"); 119 String filename = getFilename("tests/vm/data/fixed_length_file");
119 var file = (new File(filename + "_out")).openSync(FileMode.WRITE); 120 var file = (new File(filename + "_out")).openSync(FileMode.WRITE);
120 try { 121 try {
121 file.writeListSync(buffer, offset, bytes); 122 file.writeListSync(buffer, offset, bytes);
122 Expect.fail('exception expected'); 123 Expect.fail('exception expected');
123 } catch (var e) { 124 } catch (var e) {
124 Expect.isTrue(e is FileIOException); 125 Expect.isTrue(e is FileIOException);
125 Expect.isTrue(e.toString().contains('Invalid arguments')); 126 Expect.isTrue(e.toString().contains('Invalid arguments'));
126 } 127 }
127 128
128 var errors = 0; 129 var errors = 0;
129 file.errorHandler = (s) { 130 file.errorHandler = (s) {
130 errors++; 131 errors++;
131 Expect.isTrue(s.contains('Invalid arguments')); 132 Expect.isTrue(s.contains('Invalid arguments'));
132 }; 133 };
133 file.noPendingWriteHandler = (bytes) { 134 var calls = 0;
134 Expect.fail('write list invalid argument'); 135 file.noPendingWriteHandler = () {
136 if (++calls > 1) Expect.fail('write string invalid argument');
135 }; 137 };
136 file.writeList(buffer, offset, bytes); 138 file.writeList(buffer, offset, bytes);
137 file.closeHandler = () { 139 file.closeHandler = () {
138 Expect.equals(1, errors); 140 Expect.equals(1, errors);
139 }; 141 };
140 file.close(); 142 file.close();
141 } 143 }
142 144
143 static void testWriteStringInvalidArgs(string) { 145 static void testWriteStringInvalidArgs(string) {
144 String filename = getFilename("tests/vm/data/fixed_length_file"); 146 String filename = getFilename("tests/vm/data/fixed_length_file");
145 var file = new File(filename + "_out"); 147 var file = new File(filename + "_out");
146 file.openSync(FileMode.WRITE); 148 file.openSync(FileMode.WRITE);
147 try { 149 try {
148 file.writeString(string); 150 file.writeString(string);
149 Expect.fail('exception expected'); 151 Expect.fail('exception expected');
150 } catch (var e) { 152 } catch (var e) {
151 Expect.isTrue(e is FileIOException); 153 Expect.isTrue(e is FileIOException);
152 Expect.isTrue(e.toString().contains('writeString failed')); 154 Expect.isTrue(e.toString().contains('writeString failed'));
153 } 155 }
154 156
155 var errors = 0; 157 var errors = 0;
156 file.errorHandler = (s) { 158 file.errorHandler = (s) {
157 errors++; 159 errors++;
158 Expect.isTrue(s.contains('writeString failed')); 160 Expect.isTrue(s.contains('writeString failed'));
159 }; 161 };
160 file.noPendingWriteHandler = (bytes) { 162 var calls = 0;
161 Expect.fail('write string invalid argument'); 163 file.noPendingWriteHandler = () {
164 if (++calls > 1) Expect.fail('write list invalid argument');
162 }; 165 };
163 file.writeString(string); 166 file.writeString(string);
164 file.closeHandler = () { 167 file.closeHandler = () {
165 Expect.equals(1, errors); 168 Expect.equals(1, errors);
166 }; 169 };
167 file.close(); 170 file.close();
168 } 171 }
169 172
170 static void testFullPathInvalidArgs(name) { 173 static void testFullPathInvalidArgs(name) {
171 var file = new File(name); 174 var file = new File(name);
(...skipping 25 matching lines...) Expand all
197 FileTest.testCreateInvalidArgs(0); 200 FileTest.testCreateInvalidArgs(0);
198 FileTest.testReadListInvalidArgs(12, 0, 1); 201 FileTest.testReadListInvalidArgs(12, 0, 1);
199 FileTest.testReadListInvalidArgs(new List(10), '0', 1); 202 FileTest.testReadListInvalidArgs(new List(10), '0', 1);
200 FileTest.testReadListInvalidArgs(new List(10), 0, '1'); 203 FileTest.testReadListInvalidArgs(new List(10), 0, '1');
201 FileTest.testWriteByteInvalidArgs('asdf'); 204 FileTest.testWriteByteInvalidArgs('asdf');
202 FileTest.testWriteListInvalidArgs(12, 0, 1); 205 FileTest.testWriteListInvalidArgs(12, 0, 1);
203 FileTest.testWriteListInvalidArgs(new List(10), '0', 1); 206 FileTest.testWriteListInvalidArgs(new List(10), '0', 1);
204 FileTest.testWriteListInvalidArgs(new List(10), 0, '1'); 207 FileTest.testWriteListInvalidArgs(new List(10), 0, '1');
205 FileTest.testFullPathInvalidArgs(12); 208 FileTest.testFullPathInvalidArgs(12);
206 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698