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

Side by Side Diff: samples/tests/samples/src/proxy/MintMakerPromiseWithStubs_generatedTest.dart

Issue 10153005: unittest step 3 and 4: remove TestFramework.dart, make test.dart use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse 5 // IsolateStubs=MintMakerPromiseWithStubsTest.dart:Mint,Purse
6 6
7 #library("MintMakerPromiseWithStubsTest_generatedTest"); 7 #library("MintMakerPromiseWithStubsTest_generatedTest");
8 #import("dart:isolate"); 8 #import("dart:isolate");
9 #import("../../../../proxy/promise.dart"); 9 #import("../../../../proxy/promise.dart");
10 #import("../../../../../tests/isolate/src/TestFramework.dart"); 10 #import("../../../../../lib/unittest/unittest.dart");
11 11
12 /* class = Mint (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/Min tMakerPromiseWithStubsTest.dart: 10) */ 12 /* class = Mint (tests/stub-generator/src/MintMakerPromiseWithStubsTest.dart/Min tMakerPromiseWithStubsTest.dart: 10) */
13 13
14 interface Mint$Proxy extends Proxy { 14 interface Mint$Proxy extends Proxy {
15 Purse$Proxy createPurse(int balance); 15 Purse$Proxy createPurse(int balance);
16 } 16 }
17 17
18 class Mint$ProxyImpl extends ProxyImpl implements Mint$Proxy { 18 class Mint$ProxyImpl extends ProxyImpl implements Mint$Proxy {
19 Mint$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { } 19 Mint$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { }
20 Mint$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.call([null]) ) { } 20 Mint$ProxyImpl.forIsolate(Proxy isolate) : super.forReply(isolate.call([null]) ) { }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 balance.complete(_balance); 201 balance.complete(_balance);
202 }); 202 });
203 return balance; 203 return balance;
204 } 204 }
205 205
206 Mint _mint; 206 Mint _mint;
207 int _balance; 207 int _balance;
208 208
209 } 209 }
210 210
211 class MintMakerPromiseWithStubsTest { 211 _completesWithValue(Promise promise, var expected) {
212 promise.then(expectAsync1((value) {
213 Expect.equals(expected, value);
214 }));
215 }
212 216
213 static completesWithValue( 217 main() {
214 TestExpectation expect, Promise promise, var expected) { 218 test("MintMakerPromiseWithStubsTest", () {
215 promise.then(expect.runs1((value) {
216 Expect.equals(expected, value);
217 }));
218 }
219
220 static void testMain(TestExpectation expect) {
221 Mint$Proxy mint = new Mint$ProxyImpl.createIsolate(); 219 Mint$Proxy mint = new Mint$ProxyImpl.createIsolate();
222 Purse$Proxy purse = mint.createPurse(100); 220 Purse$Proxy purse = mint.createPurse(100);
223 completesWithValue(expect, purse.queryBalance(), 100); 221 _completesWithValue(purse.queryBalance(), 100);
224 222
225 Purse$Proxy sprouted = purse.sproutPurse(); 223 Purse$Proxy sprouted = purse.sproutPurse();
226 completesWithValue(expect, sprouted.queryBalance(), 0); 224 _completesWithValue(sprouted.queryBalance(), 0);
227 225
228 // FIXME(benl): We should not have to manually order the calls 226 // FIXME(benl): We should not have to manually order the calls
229 // like this. 227 // like this.
230 Promise<int> result = sprouted.deposit(5, purse); 228 Promise<int> result = sprouted.deposit(5, purse);
231 Promise p1 = result; 229 Promise p1 = result;
232 completesWithValue(expect, result, 5); 230 _completesWithValue(result, 5);
233 Promise<bool> p2 = new Promise<bool>(); 231 Promise<bool> p2 = new Promise<bool>();
234 Promise<bool> p3 = new Promise<bool>(); 232 Promise<bool> p3 = new Promise<bool>();
235 Promise<bool> p4 = new Promise<bool>(); 233 Promise<bool> p4 = new Promise<bool>();
236 Promise<bool> p5 = new Promise<bool>(); 234 Promise<bool> p5 = new Promise<bool>();
237 Promise<bool> p6 = new Promise<bool>(); 235 Promise<bool> p6 = new Promise<bool>();
238 result.addCompleteHandler((unused) { 236 result.addCompleteHandler(expectAsync1((unused) {
239 Promise<int> bal1 = sprouted.queryBalance(); 237 Promise<int> bal1 = sprouted.queryBalance();
240 completesWithValue(expect, bal1, 0 + 5); 238 _completesWithValue(bal1, 0 + 5);
241 bal1.then(expect.runs1((unused_) => p2.complete(true))); 239 bal1.then(expectAsync1((unused_) => p2.complete(true)));
242 Promise<int> bal2 = purse.queryBalance(); 240 Promise<int> bal2 = purse.queryBalance();
243 completesWithValue(expect, bal2, 100 - 5); 241 _completesWithValue(bal2, 100 - 5);
244 bal2.then(expect.runs1((unused_) => p3.complete(true))); 242 bal2.then(expectAsync1((unused_) => p3.complete(true)));
245 243
246 result = sprouted.deposit(42, purse); 244 result = sprouted.deposit(42, purse);
247 completesWithValue(expect, result, 5 + 42); 245 _completesWithValue(result, 5 + 42);
248 result.then(expect.runs1((unused__) => p4.complete(true))); 246 result.then(expectAsync1((unused__) => p4.complete(true)));
249 result.addCompleteHandler((unused_) { 247 result.addCompleteHandler(expectAsync1((unused_) {
250 Promise<int> bal3 = sprouted.queryBalance(); 248 Promise<int> bal3 = sprouted.queryBalance();
251 completesWithValue(expect, bal3, 0 + 5 + 42); 249 _completesWithValue(bal3, 0 + 5 + 42);
252 bal3.then(expect.runs1((unused___) => p5.complete(true))); 250 bal3.then(expectAsync1((unused___) => p5.complete(true)));
253 Promise<int> bal4 = purse.queryBalance(); 251 Promise<int> bal4 = purse.queryBalance();
254 completesWithValue(expect, bal4, 100 - 5 - 42); 252 _completesWithValue(bal4, 100 - 5 - 42);
255 bal4.then(expect.runs1((unused___) => p6.complete(true))); 253 bal4.then(expectAsync1((unused___) => p6.complete(true)));
256 }); 254 }));
257 }); 255 }));
258 Promise<bool> done = new Promise<bool>(); 256 Promise<bool> done = new Promise<bool>();
259 done.waitFor([p1, p2, p3, p4, p5, p6], 6); 257 done.waitFor([p1, p2, p3, p4, p5, p6], 6);
260 done.then((_) { 258 done.then((_) {
261 expect.succeeded();
262 print("##DONE##"); 259 print("##DONE##");
263 }); 260 });
264 } 261 });
265
266 } 262 }
267
268 main() {
269 runTests([MintMakerPromiseWithStubsTest.testMain]);
270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698