OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Dart test program for testing file I/O. | 5 // Dart test program for testing file I/O. |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 }); | 160 }); |
161 | 161 |
162 // Immediate read should read 0 bytes. | 162 // Immediate read should read 0 bytes. |
163 input.listen( | 163 input.listen( |
164 (d) { | 164 (d) { |
165 for (int i = 0; i < d.length; ++i) { | 165 for (int i = 0; i < d.length; ++i) { |
166 Expect.equals(buffer[(i + position) % buffer.length], d[i]); | 166 Expect.equals(buffer[(i + position) % buffer.length], d[i]); |
167 } | 167 } |
168 position += d.length; | 168 position += d.length; |
169 }, | 169 }, |
170 onError: (error) { | 170 onError: (error, trace) { |
171 print('Error on input in testReadWriteStreamLargeFile'); | 171 print('Error on input in testReadWriteStreamLargeFile'); |
172 print('with error $error'); | 172 print('with error $error'); |
173 var trace = getAttachedStackTrace(error); | |
174 if (trace != null) print("StackTrace: $trace"); | 173 if (trace != null) print("StackTrace: $trace"); |
175 throw error; | 174 throw error; |
176 }, | 175 }, |
177 onDone: () { | 176 onDone: () { |
178 Expect.equals(expectedLength, position); | 177 Expect.equals(expectedLength, position); |
179 testPipe(file, buffer) | 178 testPipe(file, buffer) |
180 .then((_) => file.delete()) | 179 .then((_) => file.delete()) |
181 .then((_) { | 180 .then((_) { |
182 asyncTestDone('testReadWriteStreamLargeFile: main test'); | 181 asyncTestDone('testReadWriteStreamLargeFile: main test'); |
183 }) | 182 }) |
184 .catchError((e) { | 183 .catchError((e, trace) { |
185 print('Exception while deleting ReadWriteStreamLargeFile file'); | 184 print('Exception while deleting ReadWriteStreamLargeFile file'); |
186 print('Exception $e'); | 185 print('Exception $e'); |
187 var trace = getAttachedStackTrace(e); | |
188 if (trace != null) print("StackTrace: $trace"); | 186 if (trace != null) print("StackTrace: $trace"); |
189 }); | 187 }); |
190 }); | 188 }); |
191 }); | 189 }); |
192 } | 190 } |
193 | 191 |
194 static Future testPipe(File file, buffer) { | 192 static Future testPipe(File file, buffer) { |
195 String outputFilename = '${file.path}_copy'; | 193 String outputFilename = '${file.path}_copy'; |
196 File outputFile = new File(outputFilename); | 194 File outputFile = new File(outputFilename); |
197 var input = file.openRead(); | 195 var input = file.openRead(); |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 testLastModified(); | 1326 testLastModified(); |
1329 testDoubleAsyncOperation(); | 1327 testDoubleAsyncOperation(); |
1330 asyncEnd(); | 1328 asyncEnd(); |
1331 }); | 1329 }); |
1332 } | 1330 } |
1333 } | 1331 } |
1334 | 1332 |
1335 main() { | 1333 main() { |
1336 FileTest.testMain(); | 1334 FileTest.testMain(); |
1337 } | 1335 } |
OLD | NEW |