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