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

Side by Side Diff: frog/tests/await/src/MintMakerRpcTest.dart

Issue 10250002: test rename overhaul: step 5 - frog and leg tests (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
(Empty)
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 // Copy of MintMakerRpcTest (under tests/isolate/src/) but rewritten using
6 // await.
7
8 #import('../../../await/samples/mintmaker/mintmaker.dart');
9
10 main() {
11 print("starting test");
12 MintProxy mint = new MintIsolate().open();
13
14 PurseProxy purse1 = await mint.createPurse(100);
15 Expect.equals(100, await purse1.queryBalance());
16 PurseProxy purse2 = await mint.createPurse(0);
17 Expect.equals(0, await purse2.queryBalance());
18
19 Expect.equals(0 + 5, await purse2.deposit(5, purse1));
20 Expect.equals(100 - 5, await purse1.queryBalance());
21
22 int balance2 = await purse2.deposit(42, purse1);
23 int balance1 = await purse1.queryBalance();
24 Expect.equals(0 + 5 + 42, balance2);
25 Expect.equals(100 - 5 - 42, balance1);
26
27 // Now try to deposit more money into purse1 than
28 // is currently in purse2. Make sure we get an exception
29 // doing this.
30 bool exceptionThrown = false;
31 try {
32 await purse1.deposit(1000, purse2);
33 } catch (exception) {
34 if (exception.toString() == "OverdraftException") {
35 print("Correctly detected overdraft.");
36 exceptionThrown = true;
37 } else {
38 throw exception;
39 }
40 }
41 if (!exceptionThrown) {
42 // Should never arrive here because there are
43 // insufficient funds to actually do the deposit
44 Expect.fail("did not detect overdraft");
45 }
46
47 // Check that the balance in each purse is unchanged from
48 // before we attempted to do the overdraft.
49 Expect.equals(balance1, await purse1.queryBalance());
50 Expect.equals(balance2, await purse2.queryBalance());
51
52 // OK, we're all done now, close down the mint isolate
53 print(await mint.close());
54 print("exit main");
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698