| 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 "dart:convert"; | 6 import "dart:convert"; |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 | 8 |
| 9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 test(-1, null); | 226 test(-1, null); |
| 227 test(100, 99); | 227 test(100, 99); |
| 228 test(null, -1); | 228 test(null, -1); |
| 229 } | 229 } |
| 230 | 230 |
| 231 | 231 |
| 232 void testStringLineSplitterEnding(String name, int length) { | 232 void testStringLineSplitterEnding(String name, int length) { |
| 233 String fileName = getFilename("tests/standalone/io/$name"); | 233 String fileName = getFilename("tests/standalone/io/$name"); |
| 234 // File contains 10 lines. | 234 // File contains 10 lines. |
| 235 File file = new File(fileName); | 235 File file = new File(fileName); |
| 236 Expect.equals(length, file.openSync().lengthSync()); | 236 Expect.equals(length, file.lengthSync()); |
| 237 var lineStream = file.openRead() | 237 var lineStream = file.openRead() |
| 238 .transform(UTF8.decoder) | 238 .transform(UTF8.decoder) |
| 239 .transform(new LineSplitter()); | 239 .transform(new LineSplitter()); |
| 240 int lineCount = 0; | 240 int lineCount = 0; |
| 241 lineStream.listen( | 241 lineStream.listen( |
| 242 (line) { | 242 (line) { |
| 243 lineCount++; | 243 lineCount++; |
| 244 Expect.isTrue(lineCount <= 10); | 244 Expect.isTrue(lineCount <= 10); |
| 245 if (line[0] != "#") { | 245 if (line[0] != "#") { |
| 246 Expect.equals("Line $lineCount", line); | 246 Expect.equals("Line $lineCount", line); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 259 testInputStreamDelete(); | 259 testInputStreamDelete(); |
| 260 testInputStreamAppend(); | 260 testInputStreamAppend(); |
| 261 testInputStreamOffset(); | 261 testInputStreamOffset(); |
| 262 testInputStreamBadOffset(); | 262 testInputStreamBadOffset(); |
| 263 // Check the length of these files as both are text files where one | 263 // Check the length of these files as both are text files where one |
| 264 // is without a terminating line separator which can easily be added | 264 // is without a terminating line separator which can easily be added |
| 265 // back if accidentally opened in a text editor. | 265 // back if accidentally opened in a text editor. |
| 266 testStringLineSplitterEnding("readline_test1.dat", 111); | 266 testStringLineSplitterEnding("readline_test1.dat", 111); |
| 267 testStringLineSplitterEnding("readline_test2.dat", 114); | 267 testStringLineSplitterEnding("readline_test2.dat", 114); |
| 268 } | 268 } |
| OLD | NEW |