Chromium Code Reviews| Index: tests/isolate/src/CountTest.dart |
| diff --git a/tests/isolate/src/CountTest.dart b/tests/isolate/src/CountTest.dart |
| index 97b6f89b2d63a9407d6a6f1ec06878ca7fc7fae4..3ccd9517749f72fde3c0c0e7cabfe46dea188a1f 100644 |
| --- a/tests/isolate/src/CountTest.dart |
| +++ b/tests/isolate/src/CountTest.dart |
| @@ -4,7 +4,7 @@ |
| #library("CountTest"); |
| #import('dart:isolate'); |
| -#import("TestFramework.dart"); |
| +#import('../../../lib/unittest/unittest.dart'); |
| class TestIsolate extends Isolate { |
| @@ -27,33 +27,29 @@ class TestIsolate extends Isolate { |
| } |
| } |
| -void test(TestExpectation expect) { |
| - int count = 0; |
| - expect.completes(new TestIsolate().spawn()).then((SendPort remote) { |
| - ReceivePort local = new ReceivePort(); |
| - SendPort reply = local.toSendPort(); |
| - |
| - local.receive(expect.runs2((int message, SendPort replyTo) { |
|
Siggi Cherem (dart-lang)
2012/04/20 00:58:23
this is called more than once, so 'later2' is not
|
| - if (message == -1) { |
| - Expect.equals(11, count); |
| - local.close(); |
| - expect.succeeded(); |
| - return; |
| - } |
| - |
| - Expect.equals((count - 1) * 2, message); |
| +void main() { |
| + test("count 10 consecutive messages", () { |
| + int count = 0; |
| + new TestIsolate().spawn().then(later1((SendPort remote) { |
| + ReceivePort local = new ReceivePort(); |
| + SendPort reply = local.toSendPort(); |
| + |
| + Function done = later0(() {}); |
|
Bob Nystrom
2012/04/20 22:31:36
This is hackish. Either our API should support thi
Siggi Cherem (dart-lang)
2012/04/21 00:03:43
How about these names?
- calledOnce(f): replacing
|
| + local.receive((int message, SendPort replyTo) { |
| + if (message == -1) { |
| + Expect.equals(11, count); |
| + local.close(); |
| + done(); |
| + return; |
| + } |
| + |
| + Expect.equals((count - 1) * 2, message); |
| + remote.send(count++, reply); |
| + if (count == 10) { |
| + remote.send(-1, reply); |
| + } |
| + }); |
| remote.send(count++, reply); |
| - if (count == 10) { |
| - remote.send(-1, reply); |
| - } |
| })); |
| - remote.send(count++, reply); |
| }); |
| } |
| - |
| -void main() { |
| - runTests([test]); |
| -} |
| - |
| - |
| - |