| 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 // Testing file input stream, VM-only, standalone test. | 4 // Testing file input stream, VM-only, standalone test. |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 import "dart:isolate"; | 8 import "dart:isolate"; |
| 9 | 9 |
| 10 // Helper method to be able to run the test from the runtime | 10 // Helper method to be able to run the test from the runtime |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 var keepAlive = new ReceivePort(); | 205 var keepAlive = new ReceivePort(); |
| 206 var temp = new Directory('').createTempSync(); | 206 var temp = new Directory('').createTempSync(); |
| 207 var file = new File('${temp.path}/input_stream_bad_offset.txt'); | 207 var file = new File('${temp.path}/input_stream_bad_offset.txt'); |
| 208 var originalLength = writeLongFileSync(file); | 208 var originalLength = writeLongFileSync(file); |
| 209 var streamedBytes = 0; | 209 var streamedBytes = 0; |
| 210 file.openRead(start, end).listen( | 210 file.openRead(start, end).listen( |
| 211 (d) { | 211 (d) { |
| 212 streamedBytes += d.length; | 212 streamedBytes += d.length; |
| 213 }, | 213 }, |
| 214 onDone: () { | 214 onDone: () { |
| 215 temp.delete(recursive: true); |
| 215 }, | 216 }, |
| 216 onError: (e) { | 217 onError: (e) { |
| 217 temp.delete(recursive: true).then((_) => keepAlive.close()); | 218 keepAlive.close(); |
| 218 }); | 219 }); |
| 219 } | 220 } |
| 220 test(-1, null); | 221 test(-1, null); |
| 221 test(100, 99); | 222 test(100, 99); |
| 222 test(null, -1); | 223 test(null, -1); |
| 223 } | 224 } |
| 224 | 225 |
| 225 | 226 |
| 226 void testStringLineTransformerEnding(String name, int length) { | 227 void testStringLineTransformerEnding(String name, int length) { |
| 227 String fileName = getFilename("tests/standalone/io/$name"); | 228 String fileName = getFilename("tests/standalone/io/$name"); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 253 testInputStreamDelete(); | 254 testInputStreamDelete(); |
| 254 testInputStreamAppend(); | 255 testInputStreamAppend(); |
| 255 testInputStreamOffset(); | 256 testInputStreamOffset(); |
| 256 testInputStreamBadOffset(); | 257 testInputStreamBadOffset(); |
| 257 // Check the length of these files as both are text files where one | 258 // Check the length of these files as both are text files where one |
| 258 // is without a terminating line separator which can easily be added | 259 // is without a terminating line separator which can easily be added |
| 259 // back if accidentally opened in a text editor. | 260 // back if accidentally opened in a text editor. |
| 260 testStringLineTransformerEnding("readline_test1.dat", 111); | 261 testStringLineTransformerEnding("readline_test1.dat", 111); |
| 261 testStringLineTransformerEnding("readline_test2.dat", 114); | 262 testStringLineTransformerEnding("readline_test2.dat", 114); |
| 262 } | 263 } |
| OLD | NEW |