| Index: tests/standalone/io/file_input_stream_test.dart
 | 
| diff --git a/tests/standalone/io/file_input_stream_test.dart b/tests/standalone/io/file_input_stream_test.dart
 | 
| index 88615a664b701258deb53f3214099709ad4817d3..25fe3658d60d20b10d055ef2a9e339b2613b5ecb 100644
 | 
| --- a/tests/standalone/io/file_input_stream_test.dart
 | 
| +++ b/tests/standalone/io/file_input_stream_test.dart
 | 
| @@ -22,9 +22,8 @@ void testStringLineSplitter() {
 | 
|    // File contains "Hello Dart\nwassup!\n"
 | 
|    File file = new File(fileName);
 | 
|    int linesRead = 0;
 | 
| -  var lineStream = file.openRead()
 | 
| -    .transform(UTF8.decoder)
 | 
| -    .transform(new LineSplitter());
 | 
| +  var lineStream =
 | 
| +      file.openRead().transform(UTF8.decoder).transform(new LineSplitter());
 | 
|    lineStream.listen((line) {
 | 
|      linesRead++;
 | 
|      if (linesRead == 1) {
 | 
| @@ -37,22 +36,19 @@ void testStringLineSplitter() {
 | 
|    });
 | 
|  }
 | 
|  
 | 
| -
 | 
|  void testOpenStreamAsync() {
 | 
|    asyncStart();
 | 
|    String fileName = getFilename("readuntil_test.dat");
 | 
|    // File contains "Hello Dart\nwassup!\n"
 | 
|    var expected = "Hello Dart\nwassup!\n".codeUnits;
 | 
|    var byteCount = 0;
 | 
| -  (new File(fileName)).openRead().listen(
 | 
| -      (d) => byteCount += d.length,
 | 
| +  (new File(fileName)).openRead().listen((d) => byteCount += d.length,
 | 
|        onDone: () {
 | 
| -        Expect.equals(expected.length, byteCount);
 | 
| -        asyncEnd();
 | 
| -      });
 | 
| +    Expect.equals(expected.length, byteCount);
 | 
| +    asyncEnd();
 | 
| +  });
 | 
|  }
 | 
|  
 | 
| -
 | 
|  // Create a file that is big enough that a file stream will
 | 
|  // read it in multiple chunks.
 | 
|  int writeLongFileSync(File file) {
 | 
| @@ -67,7 +63,6 @@ int writeLongFileSync(File file) {
 | 
|    return length;
 | 
|  }
 | 
|  
 | 
| -
 | 
|  void testInputStreamTruncate() {
 | 
|    asyncStart();
 | 
|    var temp = Directory.systemTemp.createTempSync('file_input_stream_test');
 | 
| @@ -78,27 +73,24 @@ void testInputStreamTruncate() {
 | 
|    // without getting all data.
 | 
|    var streamedBytes = 0;
 | 
|    var subscription;
 | 
| -  subscription = file.openRead().listen(
 | 
| -      (d) {
 | 
| -        if (streamedBytes == 0) {
 | 
| -          subscription.pause();
 | 
| -          // Truncate the file by opening it for writing.
 | 
| -          file.open(mode: FileMode.WRITE).then((opened) {
 | 
| -            opened.close().then((_) {
 | 
| -                Expect.equals(0, file.lengthSync());
 | 
| -                subscription.resume();
 | 
| -            });
 | 
| -          });
 | 
| -        }
 | 
| -        streamedBytes += d.length;
 | 
| -      },
 | 
| -      onDone: () {
 | 
| -        Expect.isTrue(streamedBytes > 0 && streamedBytes <= originalLength);
 | 
| -        temp.delete(recursive: true).then((_) => asyncEnd());
 | 
| -      },
 | 
| -      onError: (e) {
 | 
| -        Expect.fail("Unexpected error");
 | 
| +  subscription = file.openRead().listen((d) {
 | 
| +    if (streamedBytes == 0) {
 | 
| +      subscription.pause();
 | 
| +      // Truncate the file by opening it for writing.
 | 
| +      file.open(mode: FileMode.WRITE).then((opened) {
 | 
| +        opened.close().then((_) {
 | 
| +          Expect.equals(0, file.lengthSync());
 | 
| +          subscription.resume();
 | 
| +        });
 | 
|        });
 | 
| +    }
 | 
| +    streamedBytes += d.length;
 | 
| +  }, onDone: () {
 | 
| +    Expect.isTrue(streamedBytes > 0 && streamedBytes <= originalLength);
 | 
| +    temp.delete(recursive: true).then((_) => asyncEnd());
 | 
| +  }, onError: (e) {
 | 
| +    Expect.fail("Unexpected error");
 | 
| +  });
 | 
|  }
 | 
|  
 | 
|  void testInputStreamDelete() {
 | 
| @@ -111,36 +103,30 @@ void testInputStreamDelete() {
 | 
|    // without getting all data.
 | 
|    var streamedBytes = 0;
 | 
|    var subscription;
 | 
| -  subscription = file.openRead().listen(
 | 
| -      (d) {
 | 
| -        if (streamedBytes == 0) {
 | 
| -          subscription.pause();
 | 
| -          // Delete the underlying file by opening it for writing.
 | 
| -          file.delete()
 | 
| -            .then((deleted) {
 | 
| -              Expect.isFalse(deleted.existsSync());
 | 
| -              subscription.resume();
 | 
| -            })
 | 
| -            .catchError((e) {
 | 
| -              // On Windows, you cannot delete a file that is open
 | 
| -              // somewhere else. The stream has this file open
 | 
| -              // and therefore we get an error on deletion on Windows.
 | 
| -              Expect.equals('windows', Platform.operatingSystem);
 | 
| -              subscription.resume();
 | 
| -            });
 | 
| -        }
 | 
| -        streamedBytes += d.length;
 | 
| -      },
 | 
| -      onDone: () {
 | 
| -        Expect.equals(originalLength, streamedBytes);
 | 
| -        temp.delete(recursive: true).then((_) => asyncEnd());
 | 
| -      },
 | 
| -      onError: (e) {
 | 
| -        Expect.fail("Unexpected error");
 | 
| +  subscription = file.openRead().listen((d) {
 | 
| +    if (streamedBytes == 0) {
 | 
| +      subscription.pause();
 | 
| +      // Delete the underlying file by opening it for writing.
 | 
| +      file.delete().then((deleted) {
 | 
| +        Expect.isFalse(deleted.existsSync());
 | 
| +        subscription.resume();
 | 
| +      }).catchError((e) {
 | 
| +        // On Windows, you cannot delete a file that is open
 | 
| +        // somewhere else. The stream has this file open
 | 
| +        // and therefore we get an error on deletion on Windows.
 | 
| +        Expect.equals('windows', Platform.operatingSystem);
 | 
| +        subscription.resume();
 | 
|        });
 | 
| +    }
 | 
| +    streamedBytes += d.length;
 | 
| +  }, onDone: () {
 | 
| +    Expect.equals(originalLength, streamedBytes);
 | 
| +    temp.delete(recursive: true).then((_) => asyncEnd());
 | 
| +  }, onError: (e) {
 | 
| +    Expect.fail("Unexpected error");
 | 
| +  });
 | 
|  }
 | 
|  
 | 
| -
 | 
|  void testInputStreamAppend() {
 | 
|    asyncStart();
 | 
|    var temp = Directory.systemTemp.createTempSync('file_input_stream_test');
 | 
| @@ -150,30 +136,26 @@ void testInputStreamAppend() {
 | 
|    // underlying file and check that the stream gets all the data.
 | 
|    var streamedBytes = 0;
 | 
|    var subscription;
 | 
| -  subscription = file.openRead().listen(
 | 
| -      (d) {
 | 
| -        if (streamedBytes == 0) {
 | 
| -          subscription.pause();
 | 
| -          // Double the length of the underlying file.
 | 
| -          file.readAsBytes().then((bytes) {
 | 
| -            file.writeAsBytes(bytes, mode: FileMode.APPEND).then((_) {
 | 
| -              Expect.equals(2 * originalLength, file.lengthSync());
 | 
| -              subscription.resume();
 | 
| -            });
 | 
| -          });
 | 
| -        }
 | 
| -        streamedBytes += d.length;
 | 
| -      },
 | 
| -      onDone: () {
 | 
| -        Expect.equals(2 * originalLength, streamedBytes);
 | 
| -        temp.delete(recursive: true).then((_) => asyncEnd());
 | 
| -      },
 | 
| -      onError: (e) {
 | 
| -        Expect.fail("Unexpected error");
 | 
| +  subscription = file.openRead().listen((d) {
 | 
| +    if (streamedBytes == 0) {
 | 
| +      subscription.pause();
 | 
| +      // Double the length of the underlying file.
 | 
| +      file.readAsBytes().then((bytes) {
 | 
| +        file.writeAsBytes(bytes, mode: FileMode.APPEND).then((_) {
 | 
| +          Expect.equals(2 * originalLength, file.lengthSync());
 | 
| +          subscription.resume();
 | 
| +        });
 | 
|        });
 | 
| +    }
 | 
| +    streamedBytes += d.length;
 | 
| +  }, onDone: () {
 | 
| +    Expect.equals(2 * originalLength, streamedBytes);
 | 
| +    temp.delete(recursive: true).then((_) => asyncEnd());
 | 
| +  }, onError: (e) {
 | 
| +    Expect.fail("Unexpected error");
 | 
| +  });
 | 
|  }
 | 
|  
 | 
| -
 | 
|  void testInputStreamOffset() {
 | 
|    void test(int start, int end, int expectedBytes) {
 | 
|      asyncStart();
 | 
| @@ -182,18 +164,16 @@ void testInputStreamOffset() {
 | 
|      var originalLength = writeLongFileSync(file);
 | 
|      var streamedBytes = 0;
 | 
|      if (expectedBytes < 0) expectedBytes = originalLength + expectedBytes;
 | 
| -    file.openRead(start, end).listen(
 | 
| -        (d) {
 | 
| -          streamedBytes += d.length;
 | 
| -        },
 | 
| -        onDone: () {
 | 
| -          Expect.equals(expectedBytes, streamedBytes);
 | 
| -          temp.delete(recursive: true).then((_) => asyncEnd());
 | 
| -        },
 | 
| -        onError: (e) {
 | 
| -          Expect.fail("Unexpected error");
 | 
| -        });
 | 
| +    file.openRead(start, end).listen((d) {
 | 
| +      streamedBytes += d.length;
 | 
| +    }, onDone: () {
 | 
| +      Expect.equals(expectedBytes, streamedBytes);
 | 
| +      temp.delete(recursive: true).then((_) => asyncEnd());
 | 
| +    }, onError: (e) {
 | 
| +      Expect.fail("Unexpected error");
 | 
| +    });
 | 
|    }
 | 
| +
 | 
|    test(10, 20, 10);
 | 
|    test(10, 11, 1);
 | 
|    test(10, 10, 0);
 | 
| @@ -204,7 +184,6 @@ void testInputStreamOffset() {
 | 
|    test(20, null, -20);
 | 
|  }
 | 
|  
 | 
| -
 | 
|  void testInputStreamBadOffset() {
 | 
|    void test(int start, int end) {
 | 
|      asyncStart();
 | 
| @@ -213,48 +192,41 @@ void testInputStreamBadOffset() {
 | 
|      var originalLength = writeLongFileSync(file);
 | 
|      var streamedBytes = 0;
 | 
|      bool error = false;
 | 
| -    file.openRead(start, end).listen(
 | 
| -        (d) {
 | 
| -          streamedBytes += d.length;
 | 
| -        },
 | 
| -        onDone: () {
 | 
| -          Expect.isTrue(error);
 | 
| -          temp.deleteSync(recursive: true);
 | 
| -          asyncEnd();
 | 
| -        },
 | 
| -        onError: (e) {
 | 
| -          error = true;
 | 
| -        });
 | 
| +    file.openRead(start, end).listen((d) {
 | 
| +      streamedBytes += d.length;
 | 
| +    }, onDone: () {
 | 
| +      Expect.isTrue(error);
 | 
| +      temp.deleteSync(recursive: true);
 | 
| +      asyncEnd();
 | 
| +    }, onError: (e) {
 | 
| +      error = true;
 | 
| +    });
 | 
|    }
 | 
| +
 | 
|    test(-1, null);
 | 
|    test(100, 99);
 | 
|    test(null, -1);
 | 
|  }
 | 
|  
 | 
| -
 | 
|  void testStringLineSplitterEnding(String name, int length) {
 | 
|    String fileName = getFilename(name);
 | 
|    // File contains 10 lines.
 | 
|    File file = new File(fileName);
 | 
|    Expect.equals(length, file.lengthSync());
 | 
| -  var lineStream = file.openRead()
 | 
| -    .transform(UTF8.decoder)
 | 
| -    .transform(new LineSplitter());
 | 
| +  var lineStream =
 | 
| +      file.openRead().transform(UTF8.decoder).transform(new LineSplitter());
 | 
|    int lineCount = 0;
 | 
| -  lineStream.listen(
 | 
| -      (line) {
 | 
| -        lineCount++;
 | 
| -        Expect.isTrue(lineCount <= 10);
 | 
| -        if (line[0] != "#") {
 | 
| -          Expect.equals("Line $lineCount", line);
 | 
| -        }
 | 
| -      },
 | 
| -      onDone: () {
 | 
| -        Expect.equals(10, lineCount);
 | 
| -      });
 | 
| +  lineStream.listen((line) {
 | 
| +    lineCount++;
 | 
| +    Expect.isTrue(lineCount <= 10);
 | 
| +    if (line[0] != "#") {
 | 
| +      Expect.equals("Line $lineCount", line);
 | 
| +    }
 | 
| +  }, onDone: () {
 | 
| +    Expect.equals(10, lineCount);
 | 
| +  });
 | 
|  }
 | 
|  
 | 
| -
 | 
|  main() {
 | 
|    testStringLineSplitter();
 | 
|    testOpenStreamAsync();
 | 
| 
 |