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

Side by Side Diff: samples/tests/samples/src/proxy/MintMakerFullyIsolated_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, 8 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=MintMakerFullyIsolatedTest.dart:Mint,Purse,PowerfulPurse 5 // IsolateStubs=MintMakerFullyIsolatedTest.dart:Mint,Purse,PowerfulPurse
6 #library("MintMakerFullyIsolatedTest_generatedTest"); 6 #library("MintMakerFullyIsolatedTest_generatedTest");
7 #import("dart:isolate"); 7 #import("dart:isolate");
8 #import("../../../../proxy/promise.dart"); 8 #import("../../../../proxy/promise.dart");
9 #import("../../../../../tests/isolate/src/TestFramework.dart"); 9 #import("../../../../../lib/unittest/unittest.dart");
10 10
11 /* class = Purse (tests/stub-generator/src/MintMakerFullyIsolatedTest.dart/MintM akerFullyIsolatedTest.dart: 9) */ 11 /* class = Purse (tests/stub-generator/src/MintMakerFullyIsolatedTest.dart/MintM akerFullyIsolatedTest.dart: 9) */
12 12
13 interface Purse$Proxy extends Proxy { 13 interface Purse$Proxy extends Proxy {
14 Promise<int> queryBalance(); 14 Promise<int> queryBalance();
15 15
16 Purse$Proxy sproutPurse(); 16 Purse$Proxy sproutPurse();
17 17
18 Promise<int> deposit(int amount, Purse$Proxy source); 18 Promise<int> deposit(int amount, Purse$Proxy source);
19 } 19 }
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 Purse weak() { 452 Purse weak() {
453 return this; 453 return this;
454 } 454 }
455 455
456 Mint$Proxy _mint; 456 Mint$Proxy _mint;
457 int _balance; 457 int _balance;
458 458
459 } 459 }
460 460
461 461
462 class MintMakerFullyIsolatedTest { 462 _completesWithValue(Promise promise, var expected) {
463 promise.then(expectAsync1((value) {
464 Expect.equals(expected, value);
465 }));
466 }
463 467
464 static completesWithValue( 468 main() {
465 TestExpectation expect, Promise promise, var expected) { 469 test("MintMakerFullyIsolatedTest", () {
466 promise.then(expect.runs1((value) {
467 Expect.equals(expected, value);
468 }));
469 }
470
471 static void testMain(TestExpectation expect) {
472 Mint$Proxy mint = new Mint$ProxyImpl.createIsolate(); 470 Mint$Proxy mint = new Mint$ProxyImpl.createIsolate();
473 Purse$Proxy purse = mint.createPurse(100); 471 Purse$Proxy purse = mint.createPurse(100);
474 // FIXME(benl): how do I write this? 472 // FIXME(benl): how do I write this?
475 //PowerfulPurse$Proxy power = (PowerfulPurse$Proxy)purse; 473 //PowerfulPurse$Proxy power = (PowerfulPurse$Proxy)purse;
476 //expectEqualsStr("xxx", power.grab()); 474 //expectEqualsStr("xxx", power.grab());
477 Promise<int> balance = purse.queryBalance(); 475 Promise<int> balance = purse.queryBalance();
478 completesWithValue(expect, balance, 100); 476 _completesWithValue(balance, 100);
479 477
480 Purse$Proxy sprouted = purse.sproutPurse(); 478 Purse$Proxy sprouted = purse.sproutPurse();
481 completesWithValue(expect, sprouted.queryBalance(), 0); 479 _completesWithValue(sprouted.queryBalance(), 0);
482 480
483 Promise<int> done = sprouted.deposit(5, purse); 481 Promise<int> done = sprouted.deposit(5, purse);
484 Promise<int> d3 = done; 482 Promise<int> d3 = done;
485 completesWithValue(expect, done, 5); 483 _completesWithValue(done, 5);
486 Promise<int> inner = new Promise<int>(); 484 Promise<int> inner = new Promise<int>();
487 Promise<int> inner2 = new Promise<int>(); 485 Promise<int> inner2 = new Promise<int>();
488 // FIXME(benl): it should not be necessary to wait here, I think, 486 // FIXME(benl): it should not be necessary to wait here, I think,
489 // but without this, the tests seem to execute prematurely. 487 // but without this, the tests seem to execute prematurely.
490 Promise<int> d1 = done.then((val) { 488 Promise<int> d1 = done.then((val) {
491 completesWithValue(expect, sprouted.queryBalance(), 0 + 5); 489 _completesWithValue(sprouted.queryBalance(), 0 + 5);
492 completesWithValue(expect, purse.queryBalance(), 100 - 5); 490 _completesWithValue(purse.queryBalance(), 100 - 5);
493 491
494 done = sprouted.deposit(42, purse); 492 done = sprouted.deposit(42, purse);
495 completesWithValue(expect, done, 5 + 42); 493 _completesWithValue(done, 5 + 42);
496 Promise<int> d2 = done.then((val_) { 494 Promise<int> d2 = done.then((val_) {
497 Promise<int> bal1 = sprouted.queryBalance(); 495 Promise<int> bal1 = sprouted.queryBalance();
498 completesWithValue(expect, bal1, 0 + 5 + 42); 496 _completesWithValue(bal1, 0 + 5 + 42);
499 bal1.then(expect.runs1((int value) => inner.complete(0))); 497 bal1.then(expectAsync1((int value) => inner.complete(0)));
500 498
501 Promise<int> bal2 = purse.queryBalance(); 499 Promise<int> bal2 = purse.queryBalance();
502 completesWithValue(expect, bal2, 100 - 5 - 42); 500 _completesWithValue(bal2, 100 - 5 - 42);
503 bal2.then(expect.runs1((int value) => inner2.complete(0))); 501 bal2.then(expectAsync1((int value) => inner2.complete(0)));
504 return 0; 502 return 0;
505 }); 503 });
506 completesWithValue(expect, d2, 0); 504 _completesWithValue(d2, 0);
507 return 0; 505 return 0;
508 }); 506 });
509 completesWithValue(expect, d1, 0); 507 _completesWithValue(d1, 0);
510 Promise<int> allDone = new Promise<int>(); 508 Promise<int> allDone = new Promise<int>();
511 allDone.waitFor([d3, inner, inner2], 3); 509 allDone.waitFor([d3, inner, inner2], 3);
512 allDone.then((_) { 510 allDone.then((_) {
513 expect.succeeded();
514 print("##DONE##"); 511 print("##DONE##");
515 }); 512 });
516 } 513 });
517
518 } 514 }
519
520 main() {
521 runTests([MintMakerFullyIsolatedTest.testMain]);
522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698