Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart

Issue 8403040: Don't wait unnecessarily. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart
===================================================================
--- tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart (revision 734)
+++ tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart (working copy)
@@ -20,7 +20,7 @@
int queryBalance();
Purse sproutPurse();
- int deposit(int amount, Purse$Proxy source);
+ Promise<int> deposit(int amount, Purse$Proxy source);
}
@@ -57,17 +57,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;

Powered by Google App Engine
This is Rietveld 408576698