| 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:io"; |
| 7 |
| 8 import "package:async_helper/async_helper.dart"; |
| 6 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 7 import "dart:io"; | |
| 8 import "dart:isolate"; | |
| 9 | 10 |
| 10 void testOpenOutputStreamSync() { | 11 void testOpenOutputStreamSync() { |
| 11 Directory tempDirectory = new Directory('').createTempSync(); | 12 Directory tempDirectory = new Directory('').createTempSync(); |
| 12 | 13 |
| 13 // Create a port for waiting on the final result of this test. | 14 asyncStart(); |
| 14 ReceivePort done = new ReceivePort(); | |
| 15 done.receive((message, replyTo) { | |
| 16 tempDirectory.deleteSync(); | |
| 17 done.close(); | |
| 18 }); | |
| 19 | |
| 20 String fileName = "${tempDirectory.path}/test"; | 15 String fileName = "${tempDirectory.path}/test"; |
| 21 File file = new File(fileName); | 16 File file = new File(fileName); |
| 22 file.createSync(); | 17 file.createSync(); |
| 23 IOSink x = file.openWrite(); | 18 IOSink x = file.openWrite(); |
| 24 var data = [65, 66, 67]; | 19 var data = [65, 66, 67]; |
| 25 x.add(data); | 20 x.add(data); |
| 26 x.close(); | 21 x.close(); |
| 27 x.done.then((_) { | 22 x.done.then((_) { |
| 28 Expect.listEquals(file.readAsBytesSync(), data); | 23 Expect.listEquals(file.readAsBytesSync(), data); |
| 29 file.deleteSync(); | 24 file.deleteSync(); |
| 30 done.toSendPort().send("done"); | 25 tempDirectory.deleteSync(); |
| 26 asyncEnd(); |
| 31 }); | 27 }); |
| 32 } | 28 } |
| 33 | 29 |
| 34 | 30 |
| 35 main() { | 31 main() { |
| 36 testOpenOutputStreamSync(); | 32 testOpenOutputStreamSync(); |
| 37 } | 33 } |
| OLD | NEW |