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

Side by Side Diff: frog/tests/await/mint_maker_rpc_test.dart

Issue 10548047: Remove frog from the repository. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move test and update apidoc.gyp. Created 8 years, 6 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 // The next line is used to tell test.dart that this test is run by invoking
6 // awaitc.dart and passing this file as an argument (e.g. frog
7 // frog/await/awaitc.dart test.dart):
8 // VMOptions=frog/await/awaitc.dart
9
10 // Copy of MintMakerRpcTest (under tests/isolate/src/) but rewritten using
11 // await.
12
13 #import('../../../await/samples/mintmaker/mintmaker.dart');
14
15 main() {
16 print("starting test");
17 MintProxy mint = new MintIsolate().open();
18
19 PurseProxy purse1 = await mint.createPurse(100);
20 Expect.equals(100, await purse1.queryBalance());
21 PurseProxy purse2 = await mint.createPurse(0);
22 Expect.equals(0, await purse2.queryBalance());
23
24 Expect.equals(0 + 5, await purse2.deposit(5, purse1));
25 Expect.equals(100 - 5, await purse1.queryBalance());
26
27 int balance2 = await purse2.deposit(42, purse1);
28 int balance1 = await purse1.queryBalance();
29 Expect.equals(0 + 5 + 42, balance2);
30 Expect.equals(100 - 5 - 42, balance1);
31
32 // Now try to deposit more money into purse1 than
33 // is currently in purse2. Make sure we get an exception
34 // doing this.
35 bool exceptionThrown = false;
36 try {
37 await purse1.deposit(1000, purse2);
38 } catch (exception) {
39 if (exception.toString() == "OverdraftException") {
40 print("Correctly detected overdraft.");
41 exceptionThrown = true;
42 } else {
43 throw exception;
44 }
45 }
46 if (!exceptionThrown) {
47 // Should never arrive here because there are
48 // insufficient funds to actually do the deposit
49 Expect.fail("did not detect overdraft");
50 }
51
52 // Check that the balance in each purse is unchanged from
53 // before we attempted to do the overdraft.
54 Expect.equals(balance1, await purse1.queryBalance());
55 Expect.equals(balance2, await purse2.queryBalance());
56
57 // OK, we're all done now, close down the mint isolate
58 print(await mint.close());
59 print("exit main");
60 }
OLDNEW
« no previous file with comments | « frog/tests/await/initializer_negative_test.dart ('k') | frog/tests/await/multiple_declarations_normalization_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698