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

Unified Diff: samples/tests/samples/src/proxy/MintMakerFullyIsolated_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/MintMakerFullyIsolated_testSource.dart
diff --git a/tests/stub-generator/src/MintMakerFullyIsolatedTest.dart b/samples/tests/samples/src/proxy/MintMakerFullyIsolated_testSource.dart
similarity index 86%
rename from tests/stub-generator/src/MintMakerFullyIsolatedTest.dart
rename to samples/tests/samples/src/proxy/MintMakerFullyIsolated_testSource.dart
index dfc0b9eb681aa7236b0f2076a3f548725f939c2c..97ed7e657e41193778711b2c853f341b0dcb16a7 100644
--- a/tests/stub-generator/src/MintMakerFullyIsolatedTest.dart
+++ b/samples/tests/samples/src/proxy/MintMakerFullyIsolated_testSource.dart
@@ -1,10 +1,11 @@
-// 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=MintMakerFullyIsolatedTest.dart:Mint,Purse,PowerfulPurse
#library("MintMakerFullyIsolatedTest-generatedTest");
-#import("../../../tests/isolate/src/TestFramework.dart");
+#import("../../../../proxy/promise.dart");
+#import("../../../../../tests/isolate/src/TestFramework.dart");
interface Purse default PurseImpl{
Purse();
@@ -248,6 +249,12 @@ class PurseImpl implements PowerfulPurse {
class MintMakerFullyIsolatedTest {
+ 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);
@@ -255,34 +262,39 @@ class MintMakerFullyIsolatedTest {
//PowerfulPurse$Proxy power = (PowerfulPurse$Proxy)purse;
//expectEqualsStr("xxx", power.grab());
Promise<int> balance = purse.queryBalance();
- expect.completesWithValue(balance, 100);
+ completesWithValue(expect, balance, 100);
Purse$Proxy sprouted = purse.sproutPurse();
- expect.completesWithValue(sprouted.queryBalance(), 0);
+ completesWithValue(expect, sprouted.queryBalance(), 0);
Promise<int> done = sprouted.deposit(5, purse);
- Promise<int> d3 = expect.completesWithValue(done, 5);
+ Promise<int> d3 = done;
+ completesWithValue(expect, done, 5);
Promise<int> inner = new Promise<int>();
Promise<int> inner2 = new Promise<int>();
// FIXME(benl): it should not be necessary to wait here, I think,
// but without this, the tests seem to execute prematurely.
Promise<int> d1 = done.then((val) {
- expect.completesWithValue(sprouted.queryBalance(), 0 + 5);
- expect.completesWithValue(purse.queryBalance(), 100 - 5);
+ completesWithValue(expect, sprouted.queryBalance(), 0 + 5);
+ completesWithValue(expect, purse.queryBalance(), 100 - 5);
done = sprouted.deposit(42, purse);
- expect.completesWithValue(done, 5 + 42);
+ completesWithValue(expect, done, 5 + 42);
Promise<int> d2 = done.then((val_) {
- expect.completesWithValue(sprouted.queryBalance(), 0 + 5 + 42)
- .then((int value) => inner.complete(0));
- expect.completesWithValue(purse.queryBalance(), 100 - 5 - 42)
- .then((int value) => inner2.complete(0));
+ Promise<int> bal1 = sprouted.queryBalance();
+ completesWithValue(expect, bal1, 0 + 5 + 42);
+ bal1.then(expect.runs1((int value) => inner.complete(0)));
+
+ Promise<int> bal2 = purse.queryBalance();
+ completesWithValue(expect, bal2, 100 - 5 - 42);
+ bal2.then(expect.runs1((int value) => inner2.complete(0)));
+ return 0;
});
- expect.completes(d2);
+ completesWithValue(expect, d2, 0);
return 0;
});
- expect.completesWithValue(d1, 0);
+ completesWithValue(expect, d1, 0);
Promise<int> allDone = new Promise<int>();
allDone.waitFor([d3, inner, inner2], 3);
allDone.then((_) {

Powered by Google App Engine
This is Rietveld 408576698