| Index: samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_generatedTest.dart
|
| diff --git a/tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart b/samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_generatedTest.dart
|
| similarity index 84%
|
| rename from tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart
|
| rename to samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_generatedTest.dart
|
| index 6bd2d32de8429ead9174d78da1aa2f404e4cdb49..4251bf1fee0a5362edc032329ff90d48330ae0d2 100644
|
| --- a/tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart
|
| +++ b/samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_generatedTest.dart
|
| @@ -4,8 +4,9 @@
|
|
|
| // IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse
|
|
|
| -#library("MintMakerPromiseWithStubsTest-generatedTest");
|
| -#import("../../../tests/isolate/src/TestFramework.dart");
|
| +#library("MintMakerPromiseWithStubsTest_generatedTest");
|
| +#import("../../../../proxy/promise.dart");
|
| +#import("../../../../../tests/isolate/src/TestFramework.dart");
|
|
|
| /* class = Mint (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/MintMakerPromiseWithStubsTest.dart: 10) */
|
|
|
| @@ -208,37 +209,50 @@ class PurseImpl implements Purse {
|
|
|
| class MintMakerPromiseWithStubsTest {
|
|
|
| + static 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);
|
|
|