Chromium Code Reviews| Index: tests/isolate/src/MintMakerTest.dart |
| diff --git a/tests/isolate/src/MintMakerTest.dart b/tests/isolate/src/MintMakerTest.dart |
| index 2553422c1843f98729b7de3a21510bc2643637ac..3b2c2dc392348761940a6ee576946ae837ff2788 100644 |
| --- a/tests/isolate/src/MintMakerTest.dart |
| +++ b/tests/isolate/src/MintMakerTest.dart |
| @@ -7,7 +7,7 @@ |
| #library("MintMakerTest"); |
| #import("dart:isolate"); |
| - |
| +#import('../../../lib/unittest/unittest.dart'); |
| class Mint { |
| Mint() : registry_ = new Map<SendPort, Purse>() { |
| @@ -189,37 +189,33 @@ class MintMakerWrapper { |
| Future<SendPort> port_; |
| } |
| +_checkBalance(PurseWrapper wrapper, expected) { |
| + wrapper.queryBalance(later1((int balance) { |
| + Expect.equals(expected, balance); |
|
Bob Nystrom
2012/04/20 22:31:36
expect(balance).equals(expected);
?
Siggi Cherem (dart-lang)
2012/04/21 00:03:43
Done.
|
| + })); |
| +} |
| -class MintMakerTest { |
| - static void testMain() { |
| +main() { |
| + test("creating purse, deposit, and query balance", () { |
| MintMakerWrapper mintMaker = new MintMakerWrapper(); |
| - mintMaker.makeMint((MintWrapper mint) { |
| - mint.createPurse(100, (PurseWrapper purse) { |
| - purse.queryBalance((int balance) { |
| - Expect.equals(100, balance); |
| - }); |
| - purse.sproutPurse((PurseWrapper sprouted) { |
| - sprouted.queryBalance((int balance) { |
| - Expect.equals(0, balance); |
| - }); |
| + mintMaker.makeMint(later1((MintWrapper mint) { |
| + mint.createPurse(100, later1((PurseWrapper purse) { |
| + _checkBalance(purse, 100); |
| + purse.sproutPurse(later1((PurseWrapper sprouted) { |
| + _checkBalance(sprouted, 0); |
| + _checkBalance(purse, 100); |
| + |
| sprouted.deposit(purse, 5); |
| - sprouted.queryBalance((int balance) { |
| - Expect.equals(0 + 5, balance); |
| - }); |
| - purse.queryBalance((int balance) { |
| - Expect.equals(100 - 5, balance); |
| - }); |
| + _checkBalance(sprouted, 0 + 5); |
| + _checkBalance(purse, 100 - 5); |
| + |
| sprouted.deposit(purse, 42); |
| - sprouted.queryBalance((int balance) { |
| - Expect.equals(0 + 5 + 42, balance); |
| - }); |
| - purse.queryBalance((int balance) { |
| - Expect.equals(100 - 5 - 42, balance); |
| - }); |
| - }); |
| - }); |
| - }); |
| - } |
| + _checkBalance(sprouted, 0 + 5 + 42); |
| + _checkBalance(purse, 100 - 5 - 42); |
| + })); |
| + })); |
| + })); |
| + }); |
| /* This is an attempt to show how the above code could look like if we had |
| * better language support for asynchronous messages (deferred/asynccall). |
| @@ -267,9 +263,4 @@ class MintMakerTest { |
| Expect.equals(100 - 5 - 42, purse.queryBalance()); |
| } |
| */ |
| - |
| -} |
| - |
| -main() { |
| - MintMakerTest.testMain(); |
| } |