Index: tests/isolate/start_paused_test.dart |
diff --git a/tests/isolate/start_paused_test.dart b/tests/isolate/start_paused_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..02209a085b2158bd2a4e39b7d7227ac8ec60b91c |
--- /dev/null |
+++ b/tests/isolate/start_paused_test.dart |
@@ -0,0 +1,66 @@ |
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library start_paused_test; |
+ |
+import "dart:isolate"; |
+import "package:expect/expect.dart"; |
+import "package:async_helper/async_helper.dart"; |
+ |
+void isomain(SendPort p) { |
+ p.send("DONE"); |
+} |
+ |
+void notyet(_) { |
+ throw "NOT YET"; |
+} |
+ |
+void main() { |
+ test1(); |
+ test2(); |
+} |
+ |
+void test1() { |
+ // Test that a paused isolate don't send events. |
floitsch
2014/02/14 14:21:38
doesn't
floitsch
2014/02/14 14:21:38
Add a small description of how you test:
"We spawn
|
+ asyncStart(); |
floitsch
2014/02/14 14:21:38
missing asyncEnd
|
+ RawReceivePort p1 = new RawReceivePort(notyet); |
+ Isolate.spawn(isomain, p1.sendPort, startPaused: true) |
+ .then((isolate) { |
+ RawReceivePort p2; |
+ p2 = new RawReceivePort((x) { |
+ Expect.equals("DONE", x); |
+ p2.close(); |
+ p1.handler = (x) { |
+ Expect.equals("DONE", x); |
+ p1.close(); |
+ }; |
+ isolate.resume(isolate.pauseCapability); |
+ }); |
+ Isolate.spawn(isomain, p2.sendPort); |
+ }); |
+} |
+ |
+void test2() { |
+ // Test that a paused isolate don't send events. |
floitsch
2014/02/14 14:21:38
doesn't
|
+ asyncStart(); |
floitsch
2014/02/14 14:21:38
missing asyncEnd
|
+ RawReceivePort p1 = new RawReceivePort(notyet); |
+ Isolate.spawn(isomain, p1.sendPort, startPaused: true) |
+ .then((isolate) { |
+ RawReceivePort p2; |
+ Capability c2 = new Capability(); |
+ // Switch to another pause capability. |
+ isolate.pause(c2); |
+ isolate.resume(isolate.pauseCapability); |
+ p2 = new RawReceivePort((x) { |
+ Expect.equals("DONE", x); |
+ p2.close(); |
+ p1.handler = (x) { |
+ Expect.equals("DONE", x); |
+ p1.close(); |
+ }; |
+ isolate.resume(c2); |
+ }); |
+ Isolate.spawn(isomain, p2.sendPort); |
+ }); |
+} |