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

Unified Diff: tests/isolate/src/MintMakerTest.dart

Issue 10153005: unittest step 3 and 4: remove TestFramework.dart, make test.dart use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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
« no previous file with comments | « tests/isolate/src/MessageTest.dart ('k') | tests/isolate/src/Mixed2Test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/src/MintMakerTest.dart
diff --git a/tests/isolate/src/MintMakerTest.dart b/tests/isolate/src/MintMakerTest.dart
index 2553422c1843f98729b7de3a21510bc2643637ac..72e1597e5fdad9d502246fab42943c715da15eae 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(expectAsync1((int balance) {
+ expect(balance).equals(expected);
+ }));
+}
-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(expectAsync1((MintWrapper mint) {
+ mint.createPurse(100, expectAsync1((PurseWrapper purse) {
+ _checkBalance(purse, 100);
+ purse.sproutPurse(expectAsync1((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();
}
« no previous file with comments | « tests/isolate/src/MessageTest.dart ('k') | tests/isolate/src/Mixed2Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698