| OLD | NEW |
| 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 library MintMakerTest; | 5 library MintMakerTest; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 import "remote_unittest_helper.dart"; | 9 import "remote_unittest_helper.dart"; |
| 10 | 10 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 MintMakerWrapper._(this._port); | 143 MintMakerWrapper._(this._port); |
| 144 | 144 |
| 145 void makeMint(handleMint(MintWrapper mint)) { | 145 void makeMint(handleMint(MintWrapper mint)) { |
| 146 ReceivePort reply = new ReceivePort(); | 146 ReceivePort reply = new ReceivePort(); |
| 147 reply.first.then((SendPort mint) { handleMint(new MintWrapper(mint)); }); | 147 reply.first.then((SendPort mint) { handleMint(new MintWrapper(mint)); }); |
| 148 _port.send(reply.sendPort); | 148 _port.send(reply.sendPort); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 _checkBalance(PurseWrapper wrapper, expected) { | 152 _checkBalance(PurseWrapper wrapper, expected) { |
| 153 wrapper.queryBalance(expectAsync1((int balance) { | 153 wrapper.queryBalance(expectAsync((int balance) { |
| 154 expect(balance, equals(expected)); | 154 expect(balance, equals(expected)); |
| 155 })); | 155 })); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void main([args, port]) { | 158 void main([args, port]) { |
| 159 if (testRemote(main, port)) return; | 159 if (testRemote(main, port)) return; |
| 160 test("creating purse, deposit, and query balance", () { | 160 test("creating purse, deposit, and query balance", () { |
| 161 MintMakerWrapper.create().then(expectAsync1((mintMaker) { | 161 MintMakerWrapper.create().then(expectAsync((mintMaker) { |
| 162 mintMaker.makeMint(expectAsync1((MintWrapper mint) { | 162 mintMaker.makeMint(expectAsync((MintWrapper mint) { |
| 163 mint.createPurse(100, expectAsync1((PurseWrapper purse) { | 163 mint.createPurse(100, expectAsync((PurseWrapper purse) { |
| 164 _checkBalance(purse, 100); | 164 _checkBalance(purse, 100); |
| 165 purse.sproutPurse(expectAsync1((PurseWrapper sprouted) { | 165 purse.sproutPurse(expectAsync((PurseWrapper sprouted) { |
| 166 _checkBalance(sprouted, 0); | 166 _checkBalance(sprouted, 0); |
| 167 _checkBalance(purse, 100); | 167 _checkBalance(purse, 100); |
| 168 | 168 |
| 169 sprouted.deposit(purse, 5); | 169 sprouted.deposit(purse, 5); |
| 170 _checkBalance(sprouted, 0 + 5); | 170 _checkBalance(sprouted, 0 + 5); |
| 171 _checkBalance(purse, 100 - 5); | 171 _checkBalance(purse, 100 - 5); |
| 172 | 172 |
| 173 sprouted.deposit(purse, 42); | 173 sprouted.deposit(purse, 42); |
| 174 _checkBalance(sprouted, 0 + 5 + 42); | 174 _checkBalance(sprouted, 0 + 5 + 42); |
| 175 _checkBalance(purse, 100 - 5 - 42); | 175 _checkBalance(purse, 100 - 5 - 42); |
| 176 })); | 176 })); |
| 177 })); | 177 })); |
| 178 })); | 178 })); |
| 179 })); | 179 })); |
| 180 }); | 180 }); |
| 181 } | 181 } |
| OLD | NEW |