| Index: samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart
|
| diff --git a/tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart b/samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart
|
| similarity index 69%
|
| rename from tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart
|
| rename to samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart
|
| index 161301c77fb9403fb9d2f19593bd9df66d3a1a3b..3f95d5a0734add51b0610f759c895a9fe188409a 100644
|
| --- a/tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart
|
| +++ b/samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart
|
| @@ -5,7 +5,8 @@
|
| // IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse
|
|
|
| #library("MintMakerPromiseWithStubsTest-generatedTest");
|
| -#import("../../../tests/isolate/src/TestFramework.dart");
|
| +#import("../../../../proxy/promise.dart");
|
| +#import("../../../../../tests/isolate/src/TestFramework.dart");
|
|
|
| interface Mint default MintImpl {
|
|
|
| @@ -82,37 +83,49 @@ class PurseImpl implements Purse {
|
|
|
| class MintMakerPromiseWithStubsTest {
|
|
|
| + completesWithValue(TestExpectation expect, Promise promise, var expected) {
|
| + promise.then(expect.runs1((value) {
|
| + Expect.equals(expected, value);
|
| + }));
|
| + }
|
| +
|
| static void testMain(TestExpectation expect) {
|
| Mint$Proxy mint = new Mint$ProxyImpl.createIsolate();
|
| Purse$Proxy purse = mint.createPurse(100);
|
| - expect.completesWithValue(purse.queryBalance(), 100);
|
| + completesWithValue(expect, purse.queryBalance(), 100);
|
|
|
| Purse$Proxy sprouted = purse.sproutPurse();
|
| - expect.completesWithValue(sprouted.queryBalance(), 0);
|
| + completesWithValue(expect, sprouted.queryBalance(), 0);
|
|
|
| // FIXME(benl): We should not have to manually order the calls
|
| // like this.
|
| Promise<int> result = sprouted.deposit(5, purse);
|
| - Promise p1 = expect.completesWithValue(result, 5);
|
| + Promise p1 = result;
|
| + completesWithValue(expect, result, 5);
|
| Promise<bool> p2 = new Promise<bool>();
|
| Promise<bool> p3 = new Promise<bool>();
|
| Promise<bool> p4 = new Promise<bool>();
|
| Promise<bool> p5 = new Promise<bool>();
|
| Promise<bool> p6 = new Promise<bool>();
|
| result.addCompleteHandler((unused) {
|
| - expect.completesWithValue(sprouted.queryBalance(), 0 + 5)
|
| - .then((unused_) => p2.complete(true));
|
| - expect.completesWithValue(purse.queryBalance(), 100 - 5)
|
| - .then((unused_) => p3.complete(true));
|
| + Promise<int> bal1 = sprouted.queryBalance();
|
| + completesWithValue(expect, bal1, 0 + 5);
|
| + bal1.then(expect.runs1((unused_) => p2.complete(true)));
|
| + Promise<int> bal2 = purse.queryBalance();
|
| + completesWithValue(expect, bal2, 100 - 5);
|
| + bal2.then(expect.runs1((unused_) => p3.complete(true)));
|
|
|
| result = sprouted.deposit(42, purse);
|
| - expect.completesWithValue(result, 5 + 42).then((unused__) => p4.complete(true));
|
| + completesWithValue(expect, result, 5 + 42);
|
| + result.then(expect.runs1((unused__) => p4.complete(true)));
|
| result.addCompleteHandler((unused_) {
|
| - expect.completesWithValue(sprouted.queryBalance(), 0 + 5 + 42)
|
| - .then((unused___) => p5.complete(true));
|
| - expect.completesWithValue(purse.queryBalance(), 100 - 5 - 42)
|
| - .then((unused___) => p6.complete(true));
|
| - });
|
| + Promise<int> bal3 = sprouted.queryBalance();
|
| + completesWithValue(expect, bal3, 0 + 5 + 42);
|
| + bal3.then(expect.runs1((unused___) => p5.complete(true)));
|
| + Promise<int> bal4 = purse.queryBalance();
|
| + completesWithValue(expect, bal4, 100 - 5 - 42);
|
| + bal4.then(expect.runs1((unused___) => p6.complete(true)));
|
| + });
|
| });
|
| Promise<bool> done = new Promise<bool>();
|
| done.waitFor([p1, p2, p3, p4, p5, p6], 6);
|
|
|