| Index: tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart
|
| ===================================================================
|
| --- tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart (revision 734)
|
| +++ tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart (working copy)
|
| @@ -8,7 +8,7 @@
|
|
|
| /* class = Mint (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/MintMakerPromiseWithStubsTest.dart: 9) */
|
|
|
| -interface Mint$Proxy {
|
| +interface Mint$Proxy extends Proxy {
|
| Purse$Proxy createPurse(int balance);
|
| }
|
|
|
| @@ -61,7 +61,7 @@
|
|
|
| /* class = Purse (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/MintMakerPromiseWithStubsTest.dart: 17) */
|
|
|
| -interface Purse$Proxy {
|
| +interface Purse$Proxy extends Proxy {
|
| Promise<int> queryBalance();
|
|
|
| Purse$Proxy sproutPurse();
|
| @@ -89,7 +89,7 @@
|
| }
|
|
|
| Promise<int> deposit(int amount, Purse$Proxy source) {
|
| - return this.call(["deposit", amount, source]);
|
| + return new PromiseProxy<int>(this.call(["deposit", amount, source]));
|
| }
|
| }
|
|
|
| @@ -110,13 +110,9 @@
|
| int amount = message[1];
|
| List<Promise<SendPort>> promises = new List<Promise<SendPort>>();
|
| promises.add(new PromiseProxy<SendPort>(new Promise<SendPort>.fromValue(message[2])));
|
| - Promise done = new Promise();
|
| - done.waitFor(promises, 1);
|
| - done.addCompleteHandler((_) {
|
| - Purse$Proxy source = new Purse$ProxyImpl(promises[0]);
|
| - int deposit = target.deposit(amount, source);
|
| - reply(deposit);
|
| - });
|
| + Purse$Proxy source = new Purse$ProxyImpl(promises[0]);
|
| + Promise<int> deposit = target.deposit(amount, source);
|
| + reply(deposit);
|
| } else {
|
| // TODO(kasperl,benl): Somehow throw an exception instead.
|
| reply("Exception: command '" + command + "' not understood by Purse.");
|
| @@ -150,7 +146,7 @@
|
|
|
| int queryBalance();
|
| Purse sproutPurse();
|
| - int deposit(int amount, Purse$Proxy source);
|
| + Promise<int> deposit(int amount, Purse$Proxy source);
|
|
|
| }
|
|
|
| @@ -187,17 +183,21 @@
|
| return _mint.createPurse(0);
|
| }
|
|
|
| - int deposit(int amount, Purse$Proxy proxy) {
|
| + Promise<int> deposit(int amount, Purse$Proxy proxy) {
|
| if (amount < 0) throw "Ha ha";
|
| // Because we are in the same isolate as the other purse, we can
|
| // retrieve the proxy's local PurseImpl object and act on it
|
| // directly. Further, a forged purse will not be convertible, and
|
| // so an attempt to use it will fail.
|
| - PurseImpl source = proxy.dynamic.local;
|
| - if (source._balance < amount) throw "Not enough dough.";
|
| - _balance += amount;
|
| - source._balance -= amount;
|
| - return _balance;
|
| + Promise<int> balance = new Promise<int>();
|
| + proxy.addCompleteHandler((_) {
|
| + PurseImpl source = proxy.dynamic.local;
|
| + if (source._balance < amount) throw "Not enough dough.";
|
| + _balance += amount;
|
| + source._balance -= amount;
|
| + balance.complete(_balance);
|
| + });
|
| + return balance;
|
| }
|
|
|
| Mint _mint;
|
|
|