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

Unified Diff: samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart

Issue 9401030: remove promise from corelib (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 8 years, 10 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: samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart
diff --git a/tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart b/samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart
similarity index 68%
rename from tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart
rename to samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart
index 161301c77fb9403fb9d2f19593bd9df66d3a1a3b..1219d10d3d0ab911977f8aa284420457a96903a9 100644
--- a/tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart
+++ b/samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_testSource.dart
@@ -1,11 +1,12 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, 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
#library("MintMakerPromiseWithStubsTest-generatedTest");
-#import("../../../tests/isolate/src/TestFramework.dart");
+#import("../../../../proxy/promise.dart");
+#import("../../../../../tests/isolate/src/TestFramework.dart");
interface Mint default MintImpl {
@@ -82,37 +83,49 @@ class PurseImpl implements Purse {
class MintMakerPromiseWithStubsTest {
+ completesWithValue(TestExpectation expect, Promise promise, var expected) {
+ promise.then(expect.runs1((value) {
+ Expect.equals(expected, value);
+ }));
+ }
+
static void testMain(TestExpectation expect) {
Mint$Proxy mint = new Mint$ProxyImpl.createIsolate();
Purse$Proxy purse = mint.createPurse(100);
- expect.completesWithValue(purse.queryBalance(), 100);
+ completesWithValue(expect, purse.queryBalance(), 100);
Purse$Proxy sprouted = purse.sproutPurse();
- expect.completesWithValue(sprouted.queryBalance(), 0);
+ completesWithValue(expect, sprouted.queryBalance(), 0);
// FIXME(benl): We should not have to manually order the calls
// like this.
Promise<int> result = sprouted.deposit(5, purse);
- Promise p1 = expect.completesWithValue(result, 5);
+ Promise p1 = result;
+ completesWithValue(expect, result, 5);
Promise<bool> p2 = new Promise<bool>();
Promise<bool> p3 = new Promise<bool>();
Promise<bool> p4 = new Promise<bool>();
Promise<bool> p5 = new Promise<bool>();
Promise<bool> p6 = new Promise<bool>();
result.addCompleteHandler((unused) {
- expect.completesWithValue(sprouted.queryBalance(), 0 + 5)
- .then((unused_) => p2.complete(true));
- expect.completesWithValue(purse.queryBalance(), 100 - 5)
- .then((unused_) => p3.complete(true));
+ Promise<int> bal1 = sprouted.queryBalance();
+ completesWithValue(expect, bal1, 0 + 5);
+ bal1.then(expect.runs1((unused_) => p2.complete(true)));
+ Promise<int> bal2 = purse.queryBalance();
+ completesWithValue(expect, bal2, 100 - 5);
+ bal2.then(expect.runs1((unused_) => p3.complete(true)));
result = sprouted.deposit(42, purse);
- expect.completesWithValue(result, 5 + 42).then((unused__) => p4.complete(true));
+ completesWithValue(expect, result, 5 + 42);
+ result.then(expect.runs1((unused__) => p4.complete(true)));
result.addCompleteHandler((unused_) {
- expect.completesWithValue(sprouted.queryBalance(), 0 + 5 + 42)
- .then((unused___) => p5.complete(true));
- expect.completesWithValue(purse.queryBalance(), 100 - 5 - 42)
- .then((unused___) => p6.complete(true));
- });
+ Promise<int> bal3 = sprouted.queryBalance();
+ completesWithValue(expect, bal3, 0 + 5 + 42);
+ bal3.then(expect.runs1((unused___) => p5.complete(true)));
+ Promise<int> bal4 = purse.queryBalance();
+ completesWithValue(expect, bal4, 100 - 5 - 42);
+ bal4.then(expect.runs1((unused___) => p6.complete(true)));
+ });
});
Promise<bool> done = new Promise<bool>();
done.waitFor([p1, p2, p3, p4, p5, p6], 6);

Powered by Google App Engine
This is Rietveld 408576698