| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @TestOn("vm") | 5 @TestOn("vm") |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 | 9 |
| 10 import 'package:unittest/src/backend/invoker.dart'; | 10 import 'package:unittest/src/backend/invoker.dart'; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 }, (error) { | 255 }, (error) { |
| 256 expect(error, isRemoteException("three")); | 256 expect(error, isRemoteException("three")); |
| 257 }, (error) { | 257 }, (error) { |
| 258 expect(error, isRemoteException("four")); | 258 expect(error, isRemoteException("four")); |
| 259 }]); | 259 }]); |
| 260 | 260 |
| 261 return liveTest.run(); | 261 return liveTest.run(); |
| 262 }); | 262 }); |
| 263 }); | 263 }); |
| 264 }); | 264 }); |
| 265 |
| 266 test("forwards a test's prints", () { |
| 267 return _isolateTest(_printTest).then((liveTest) { |
| 268 expect(liveTest.onPrint.take(2).toList(), |
| 269 completion(equals(["Hello,", "world!"]))); |
| 270 |
| 271 return liveTest.run(); |
| 272 }); |
| 273 }); |
| 265 } | 274 } |
| 266 | 275 |
| 267 /// Loads the first test defined in [entryPoint] in another isolate. | 276 /// Loads the first test defined in [entryPoint] in another isolate. |
| 268 /// | 277 /// |
| 269 /// This test will be automatically closed when the test is finished. | 278 /// This test will be automatically closed when the test is finished. |
| 270 Future<LiveTest> _isolateTest(void entryPoint(SendPort sendPort)) { | 279 Future<LiveTest> _isolateTest(void entryPoint(SendPort sendPort)) { |
| 271 return _spawnIsolate(entryPoint).then((receivePort) { | 280 return _spawnIsolate(entryPoint).then((receivePort) { |
| 272 return receivePort.first; | 281 return receivePort.first; |
| 273 }).then((response) { | 282 }).then((response) { |
| 274 expect(response, containsPair("type", "success")); | 283 expect(response, containsPair("type", "success")); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 IsolateListener.start(sendPort, () => () { | 382 IsolateListener.start(sendPort, () => () { |
| 374 test("multiple errors", () { | 383 test("multiple errors", () { |
| 375 Invoker.current.addOutstandingCallback(); | 384 Invoker.current.addOutstandingCallback(); |
| 376 new Future(() => throw "one"); | 385 new Future(() => throw "one"); |
| 377 new Future(() => throw "two"); | 386 new Future(() => throw "two"); |
| 378 new Future(() => throw "three"); | 387 new Future(() => throw "three"); |
| 379 new Future(() => throw "four"); | 388 new Future(() => throw "four"); |
| 380 }); | 389 }); |
| 381 }); | 390 }); |
| 382 } | 391 } |
| 392 |
| 393 /// An isolate entrypoint that defines a test that prints twice. |
| 394 void _printTest(SendPort sendPort) { |
| 395 IsolateListener.start(sendPort, () => () { |
| 396 test("prints", () { |
| 397 print("Hello,"); |
| 398 return new Future(() => print("world!")); |
| 399 }); |
| 400 }); |
| 401 } |
| 402 |
| OLD | NEW |