| 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 | 4 |
| 5 #import("dart:io"); | 5 #import("dart:io"); |
| 6 #import("dart:isolate"); | 6 #import("dart:isolate"); |
| 7 | 7 |
| 8 void testEmptyListOutputStream1() { | 8 void testEmptyListOutputStream1() { |
| 9 ListOutputStream stream = new ListOutputStream(); | 9 ListOutputStream stream = new ListOutputStream(); |
| 10 Expect.equals(null, stream.read()); | 10 Expect.equals(null, stream.read()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 new Timer(0, (_) { | 132 new Timer(0, (_) { |
| 133 result.add(3); | 133 result.add(3); |
| 134 stream.write([4]); | 134 stream.write([4]); |
| 135 stream.close(); | 135 stream.close(); |
| 136 }); | 136 }); |
| 137 }); | 137 }); |
| 138 | 138 |
| 139 donePort.receive((x,y) => donePort.close()); | 139 donePort.receive((x,y) => donePort.close()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void testListOutputStream5() { |
| 143 ListOutputStream stream = new ListOutputStream(); |
| 144 ReceivePort donePort = new ReceivePort(); |
| 145 |
| 146 stream.onClosed = () { |
| 147 Expect.isTrue(stream.closed); |
| 148 var contents = stream.read(); |
| 149 Expect.equals(3, contents.length); |
| 150 for (var i = 0; i < contents.length; i++) Expect.equals(i + 1, contents[i]); |
| 151 donePort.toSendPort().send(null); |
| 152 }; |
| 153 |
| 154 Expect.isFalse(stream.closed); |
| 155 stream.write([1, 2, 3]); |
| 156 Expect.isFalse(stream.closed); |
| 157 stream.close(); |
| 158 Expect.isTrue(stream.closed); |
| 159 Expect.throws(() => stream.write([4, 5, 6])); |
| 160 |
| 161 donePort.receive((x,y) => donePort.close()); |
| 162 } |
| 163 |
| 142 main() { | 164 main() { |
| 143 testEmptyListOutputStream1(); | 165 testEmptyListOutputStream1(); |
| 144 testEmptyListOutputStream2(); | 166 testEmptyListOutputStream2(); |
| 145 testListOutputStream1(); | 167 testListOutputStream1(); |
| 146 testListOutputStream2(); | 168 testListOutputStream2(); |
| 147 testListOutputStream3(); | 169 testListOutputStream3(); |
| 148 testListOutputStream4(); | 170 testListOutputStream4(); |
| 171 testListOutputStream5(); |
| 149 } | 172 } |
| OLD | NEW |