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

Side by Side Diff: tests/stub-generator/src/MintMakerPromiseWithStubsTest-generatedTest.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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* class = Mint (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/Min tMakerPromiseWithStubsTest.dart: 7) */ 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse
6
7 #import("../../isolate/src/TestFramework.dart");
8
9 /* class = Mint (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/Min tMakerPromiseWithStubsTest.dart: 9) */
2 10
3 interface Mint$Proxy { 11 interface Mint$Proxy {
4 Purse$Proxy createPurse(int balance); 12 Purse$Proxy createPurse(int balance);
5 } 13 }
6 14
7 class Mint$ProxyImpl extends Proxy implements Mint$Proxy { 15 class Mint$ProxyImpl extends Proxy implements Mint$Proxy {
8 Mint$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { } 16 Mint$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { }
9 Mint$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.call([null]) ) { } 17 Mint$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.call([null]) ) { }
10 factory Mint$ProxyImpl.createIsolate() { 18 factory Mint$ProxyImpl.createIsolate() {
11 Proxy isolate = new Proxy.forIsolate(new Mint$Dispatcher$Isolate()); 19 Proxy isolate = new Proxy.forIsolate(new Mint$Dispatcher$Isolate());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void main() { 52 void main() {
45 this.port.receive(void _(var message, SendPort replyTo) { 53 this.port.receive(void _(var message, SendPort replyTo) {
46 Mint thing = new Mint(); 54 Mint thing = new Mint();
47 SendPort port = Dispatcher.serve(new Mint$Dispatcher(thing)); 55 SendPort port = Dispatcher.serve(new Mint$Dispatcher(thing));
48 Proxy proxy = new Proxy.forPort(replyTo); 56 Proxy proxy = new Proxy.forPort(replyTo);
49 proxy.send([port]); 57 proxy.send([port]);
50 }); 58 });
51 } 59 }
52 } 60 }
53 61
54 /* class = Purse (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/Mi ntMakerPromiseWithStubsTest.dart: 15) */ 62 /* class = Purse (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/Mi ntMakerPromiseWithStubsTest.dart: 17) */
55 63
56 interface Purse$Proxy { 64 interface Purse$Proxy {
57 Promise<int> queryBalance(); 65 Promise<int> queryBalance();
58 66
59 Purse$Proxy sproutPurse(); 67 Purse$Proxy sproutPurse();
60 68
61 Promise<int> deposit(int amount, Purse$Proxy source); 69 Promise<int> deposit(int amount, Purse$Proxy source);
62 } 70 }
63 71
64 class Purse$ProxyImpl extends Proxy implements Purse$Proxy { 72 class Purse$ProxyImpl extends Proxy implements Purse$Proxy {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 129
122 void main() { 130 void main() {
123 this.port.receive(void _(var message, SendPort replyTo) { 131 this.port.receive(void _(var message, SendPort replyTo) {
124 Purse thing = new Purse(); 132 Purse thing = new Purse();
125 SendPort port = Dispatcher.serve(new Purse$Dispatcher(thing)); 133 SendPort port = Dispatcher.serve(new Purse$Dispatcher(thing));
126 Proxy proxy = new Proxy.forPort(replyTo); 134 Proxy proxy = new Proxy.forPort(replyTo);
127 proxy.send([port]); 135 proxy.send([port]);
128 }); 136 });
129 } 137 }
130 } 138 }
131 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
132 // for details. All rights reserved. Use of this source code is governed by a
133 // BSD-style license that can be found in the LICENSE file.
134
135 // IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse
136
137 interface Mint factory MintImpl { 139 interface Mint factory MintImpl {
138 140
139 Mint(); 141 Mint();
140 142
141 Purse createPurse(int balance); 143 Purse createPurse(int balance);
142 144
143 } 145 }
144 146
145 interface Purse factory PurseImpl { 147 interface Purse factory PurseImpl {
146 148
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return _balance; 200 return _balance;
199 } 201 }
200 202
201 Mint _mint; 203 Mint _mint;
202 int _balance; 204 int _balance;
203 205
204 } 206 }
205 207
206 class MintMakerPromiseWithStubsTest { 208 class MintMakerPromiseWithStubsTest {
207 209
208 static void testMain() { 210 static void testMain(TestExpectation expect) {
209 Mint$Proxy mint = new Mint$ProxyImpl.createIsolate(); 211 Mint$Proxy mint = new Mint$ProxyImpl.createIsolate();
210 Purse$Proxy purse = mint.createPurse(100); 212 Purse$Proxy purse = mint.createPurse(100);
211 expectEquals(100, purse.queryBalance()); 213 expect.completesWithValue(purse.queryBalance(), 100);
212 214
213 Purse$Proxy sprouted = purse.sproutPurse(); 215 Purse$Proxy sprouted = purse.sproutPurse();
214 expectEquals(0, sprouted.queryBalance()); 216 expect.completesWithValue(sprouted.queryBalance(), 0);
215 217
216 // FIXME(benl): We should not have to manually order the calls 218 // FIXME(benl): We should not have to manually order the calls
217 // like this. 219 // like this.
218 Promise<int> result = sprouted.deposit(5, purse); 220 Promise<int> result = sprouted.deposit(5, purse);
219 expectEquals(5, result); 221 expect.completesWithValue(result, 5);
220 result.addCompleteHandler((_) { 222 result.addCompleteHandler((_) {
221 expectEquals(0 + 5, sprouted.queryBalance()); 223 expect.completesWithValue(sprouted.queryBalance(), 0 + 5);
222 expectEquals(100 - 5, purse.queryBalance()); 224 expect.completesWithValue(purse.queryBalance(), 100 - 5);
223 225
224 result = sprouted.deposit(42, purse); 226 result = sprouted.deposit(42, purse);
225 expectEquals(5 + 42, result); 227 expect.completesWithValue(result, 5 + 42);
226 result.addCompleteHandler((_) { 228 result.addCompleteHandler((_) {
227 expectEquals(0 + 5 + 42, sprouted.queryBalance()); 229 expect.completesWithValue(sprouted.queryBalance(), 0 + 5 + 42);
228 expectEquals(100 - 5 - 42, purse.queryBalance()); 230 expect.completesWithValue(purse.queryBalance(), 100 - 5 - 42);
229 expectDone(8); 231 });
230 });
231 }); 232 });
232 } 233 expect.succeeded();
233
234 static List<Promise> results;
235
236 static void expectEquals(int expected, Promise<int> promise) {
237 if (results === null) {
238 results = new List<Promise>();
239 }
240 results.add(promise.then((int actual) {
241 //print("done $expected/$actual");
242 Expect.equals(expected, actual);
243 }));
244 }
245
246 static void expectDone(int n) {
247 if (results === null) {
248 Expect.equals(0, n);
249 print('##DONE##');
250 } else {
251 Promise done = new Promise();
252 done.waitFor(results, results.length);
253 done.then((ignored) {
254 Expect.equals(n, results.length);
255 print('##DONE##');
256 });
257 }
258 } 234 }
259 235
260 } 236 }
261 237
262 main() { 238 main() {
263 MintMakerPromiseWithStubsTest.testMain(); 239 runTests([MintMakerPromiseWithStubsTest.testMain]);
264 } 240 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698