| Index: tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart
|
| ===================================================================
|
| --- tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart (revision 626)
|
| +++ tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.dart (working copy)
|
| @@ -1,5 +1,13 @@
|
| -/* class = Mint (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/MintMakerPromiseWithStubsTest.dart: 7) */
|
| +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
|
|
| +// IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse
|
| +
|
| +#import("../../isolate/src/TestFramework.dart");
|
| +
|
| +/* class = Mint (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/MintMakerPromiseWithStubsTest.dart: 9) */
|
| +
|
| interface Mint$Proxy {
|
| Purse$Proxy createPurse(int balance);
|
| }
|
| @@ -51,7 +59,7 @@
|
| }
|
| }
|
|
|
| -/* class = Purse (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/MintMakerPromiseWithStubsTest.dart: 15) */
|
| +/* class = Purse (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/MintMakerPromiseWithStubsTest.dart: 17) */
|
|
|
| interface Purse$Proxy {
|
| Promise<int> queryBalance();
|
| @@ -128,12 +136,6 @@
|
| });
|
| }
|
| }
|
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| -// for details. All rights reserved. Use of this source code is governed by a
|
| -// BSD-style license that can be found in the LICENSE file.
|
| -
|
| -// IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse
|
| -
|
| interface Mint factory MintImpl {
|
|
|
| Mint();
|
| @@ -205,60 +207,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]);
|
| }
|
|
|