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

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

Issue 8380003: Switch to new test framework. (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 626)
+++ tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart (working copy)
@@ -4,6 +4,8 @@
// IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse
+#import("../../isolate/src/TestFramework.dart");
+
interface Mint factory MintImpl {
Mint();
@@ -75,60 +77,34 @@
class MintMakerPromiseWithStubsTest {
- static void testMain() {
+ static void testMain(TestExpectation expect) {
Mint$Proxy mint = new Mint$ProxyImpl.createIsolate();
Purse$Proxy purse = mint.createPurse(100);
- expectEquals(100, purse.queryBalance());
+ expect.completesWithValue(purse.queryBalance(), 100);
Purse$Proxy sprouted = purse.sproutPurse();
- expectEquals(0, sprouted.queryBalance());
+ expect.completesWithValue(sprouted.queryBalance(), 0);
// FIXME(benl): We should not have to manually order the calls
// like this.
Promise<int> result = sprouted.deposit(5, purse);
- expectEquals(5, result);
+ expect.completesWithValue(result, 5);
result.addCompleteHandler((_) {
- expectEquals(0 + 5, sprouted.queryBalance());
- expectEquals(100 - 5, purse.queryBalance());
+ expect.completesWithValue(sprouted.queryBalance(), 0 + 5);
+ expect.completesWithValue(purse.queryBalance(), 100 - 5);
result = sprouted.deposit(42, purse);
- expectEquals(5 + 42, result);
+ expect.completesWithValue(result, 5 + 42);
result.addCompleteHandler((_) {
- expectEquals(0 + 5 + 42, sprouted.queryBalance());
- expectEquals(100 - 5 - 42, purse.queryBalance());
- expectDone(8);
- });
+ expect.completesWithValue(sprouted.queryBalance(), 0 + 5 + 42);
+ expect.completesWithValue(purse.queryBalance(), 100 - 5 - 42);
+ });
});
+ expect.succeeded();
}
- static List<Promise> results;
-
- static void expectEquals(int expected, Promise<int> promise) {
- if (results === null) {
- results = new List<Promise>();
- }
- results.add(promise.then((int actual) {
- //print("done $expected/$actual");
- Expect.equals(expected, actual);
- }));
- }
-
- static void expectDone(int n) {
- if (results === null) {
- Expect.equals(0, n);
- print('##DONE##');
- } else {
- Promise done = new Promise();
- done.waitFor(results, results.length);
- done.then((ignored) {
- Expect.equals(n, results.length);
- print('##DONE##');
- });
- }
- }
-
}
main() {
- MintMakerPromiseWithStubsTest.testMain();
+ runTests([MintMakerPromiseWithStubsTest.testMain]);
}

Powered by Google App Engine
This is Rietveld 408576698