| OLD | NEW | 
|    1 // Copyright (c) 2012, 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 // Testing file input stream, VM-only, standalone test. |    4 // Testing file input stream, VM-only, standalone test. | 
|    5  |    5  | 
|    6 #import("dart:io"); |    6 #import("dart:io"); | 
|    7 #import("dart:isolate"); |    7 #import("dart:isolate"); | 
|    8  |    8  | 
|    9 void testOpenOutputStreamSync() { |    9 void testOpenOutputStreamSync() { | 
|   10   Directory tempDirectory = new Directory('').createTempSync(); |   10   Directory tempDirectory = new Directory('').createTempSync(); | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   62           openedFile.closeSync(); |   62           openedFile.closeSync(); | 
|   63           fileSync.deleteSync(); |   63           fileSync.deleteSync(); | 
|   64           done.toSendPort().send("done"); |   64           done.toSendPort().send("done"); | 
|   65         }; |   65         }; | 
|   66       }; |   66       }; | 
|   67     }); |   67     }); | 
|   68   }); |   68   }); | 
|   69 } |   69 } | 
|   70  |   70  | 
|   71  |   71  | 
 |   72 void testOutputStreamFlush() { | 
 |   73   Directory tempDirectory = new Directory('').createTempSync(); | 
 |   74  | 
 |   75   // Create a port for waiting on the final result of this test. | 
 |   76   ReceivePort done = new ReceivePort(); | 
 |   77   done.receive((message, replyTo) { | 
 |   78     tempDirectory.deleteSync(); | 
 |   79     done.close(); | 
 |   80   }); | 
 |   81  | 
 |   82   tempDirectory.createTempSync(); | 
 |   83   String fileName = "${tempDirectory.path}/test"; | 
 |   84   File file = new File(fileName); | 
 |   85   file.createSync(); | 
 |   86   OutputStream x = file.openOutputStream(); | 
 |   87   x.write([65, 66, 67]); | 
 |   88   x.flush(); | 
 |   89   x.write([68, 69, 70]); | 
 |   90   x.flush(); | 
 |   91   x.write([71, 72, 73]); | 
 |   92   x.onClosed = () { | 
 |   93     file.deleteSync(); | 
 |   94     done.toSendPort().send("done"); | 
 |   95   }; | 
 |   96   x.close(); | 
 |   97   x.onError = (e) => Expect.fail("No error expected"); | 
 |   98 } | 
 |   99  | 
|   72 main() { |  100 main() { | 
|   73   testOpenOutputStreamSync(); |  101   testOpenOutputStreamSync(); | 
|   74   testOutputStreamNoPendingWrite(); |  102   testOutputStreamNoPendingWrite(); | 
 |  103   testOutputStreamFlush(); | 
|   75 } |  104 } | 
| OLD | NEW |