Chromium Code Reviews| Index: samples/tests/samples/src/proxy/PromiseBasedTest.dart |
| diff --git a/samples/tests/samples/src/proxy/PromiseBasedTest.dart b/samples/tests/samples/src/proxy/PromiseBasedTest.dart |
| index b9b17762537e8b4989a128090930771e91549f4b..a767da230dd88db9717adba66a9da9f152f8e042 100644 |
| --- a/samples/tests/samples/src/proxy/PromiseBasedTest.dart |
| +++ b/samples/tests/samples/src/proxy/PromiseBasedTest.dart |
| @@ -5,7 +5,7 @@ |
| #library("PromiseBasedTest"); |
| #import("dart:isolate"); |
| #import("../../../../proxy/promise.dart"); |
| -#import("../../../../../tests/isolate/src/TestFramework.dart"); |
| +#import("../../../../../lib/unittest/unittest.dart"); |
| class TestIsolate extends Isolate { |
| @@ -37,51 +37,47 @@ Future promiseToFuture(Promise p) { |
| return c.future; |
| } |
| -void test(TestExpectation expect) { |
| - Proxy proxy = new Proxy.forIsolate(new TestIsolate()); |
| - proxy.send([42]); // Seed the isolate. |
| - Promise<int> result = new PromiseProxy<int>(proxy.call([87])); |
| - Completer completer = new Completer(); |
| - expect.completes(promiseToFuture(result)).then((int value) { |
| - //print("expect 1: $value"); |
| - Expect.equals(42 + 87, value); |
| - completer.complete(99); |
| - }); |
| - expect.completes(completer.future).then((int value) { |
| - //print("expect 2: $value"); |
| - Expect.equals(99, value); |
| - expect.succeeded(); |
| +void main() { |
|
Siggi Cherem (dart-lang)
2012/04/20 00:58:23
this code is very obsolete and I'd like to remove
|
| + test("promise based proxies", () { |
| + Proxy proxy = new Proxy.forIsolate(new TestIsolate()); |
| + proxy.send([42]); // Seed the isolate. |
| + Promise<int> result = new PromiseProxy<int>(proxy.call([87])); |
| + Completer completer = new Completer(); |
| + result.then(later1((int value) { |
| + //print("expect 1: $value"); |
| + Expect.equals(42 + 87, value); |
| + completer.complete(99); |
| + })); |
| + completer.future.then(later1((int value) { |
| + //print("expect 2: $value"); |
| + Expect.equals(99, value); |
| + })); |
| }); |
| -} |
| -void expandedTest(TestExpectation expect) { |
| - Proxy proxy = new Proxy.forIsolate(new TestIsolate()); |
| - proxy.send([42]); // Seed the isolate. |
| - Promise<SendPort> sendCompleter = proxy.call([87]); |
| - Promise<int> result = new Promise<int>(); |
| - ReceivePort receivePort = new ReceivePort(); |
| - receivePort.receive((var msg, SendPort _) { |
| - receivePort.close(); |
| - //print("test completer"); |
| - result.complete(msg[0]); |
| - }); |
| - sendCompleter.addCompleteHandler((SendPort port) { |
| - //print("test send"); |
| - port.send([receivePort.toSendPort()], null); |
| - }); |
| - Completer completer = new Completer(); |
| - expect.completes(promiseToFuture(result)).then((int value) { |
| - //print("expect 1: $value"); |
| - Expect.equals(42 + 87, value); |
| - completer.complete(99); |
| - }); |
| - expect.completes(completer.future).then((int value) { |
| - //print("expect 2: $value"); |
| - Expect.equals(99, value); |
| - expect.succeeded(); |
| + test("expanded test", () { |
| + Proxy proxy = new Proxy.forIsolate(new TestIsolate()); |
| + proxy.send([42]); // Seed the isolate. |
| + Promise<SendPort> sendCompleter = proxy.call([87]); |
| + Promise<int> result = new Promise<int>(); |
| + ReceivePort receivePort = new ReceivePort(); |
| + receivePort.receive((var msg, SendPort _) { |
| + receivePort.close(); |
| + //print("test completer"); |
| + result.complete(msg[0]); |
| + }); |
| + sendCompleter.addCompleteHandler((SendPort port) { |
| + //print("test send"); |
| + port.send([receivePort.toSendPort()], null); |
| + }); |
| + Completer completer = new Completer(); |
| + promiseToFuture(result).then(later1((int value) { |
| + //print("expect 1: $value"); |
| + Expect.equals(42 + 87, value); |
| + completer.complete(99); |
| + })); |
| + completer.future.then(later1((int value) { |
| + //print("expect 2: $value"); |
| + Expect.equals(99, value); |
| + })); |
| }); |
| } |
| - |
| -void main() { |
| - runTests([test, expandedTest]); |
| -} |