| Index: runtime/vm/snapshot_test.dart
|
| diff --git a/runtime/vm/snapshot_test.dart b/runtime/vm/snapshot_test.dart
|
| index 89cf28cc8cc47cf746cac2f40e69795eb171bc8e..2cc372479d98e65ed84624158d50001bfb01af73 100644
|
| --- a/runtime/vm/snapshot_test.dart
|
| +++ b/runtime/vm/snapshot_test.dart
|
| @@ -1261,220 +1261,11 @@ class IsolateExitHandlerTest extends Isolate {
|
| }
|
| }
|
|
|
| -interface Mint default MintImpl {
|
| -
|
| - Mint();
|
| -
|
| - Purse createPurse(int balance);
|
| -
|
| -}
|
| -
|
| -
|
| -class MintImpl implements Mint {
|
| -
|
| - MintImpl() { }
|
| -
|
| - Purse createPurse(int balance) {
|
| - return new PurseImpl(this, balance);
|
| - }
|
| -
|
| -}
|
| -
|
| -
|
| -interface Purse {
|
| -
|
| - int queryBalance();
|
| - Purse sproutPurse();
|
| - void deposit(int amount, Purse$Proxy source);
|
| -
|
| -}
|
| -
|
| -
|
| -class PurseImpl implements Purse {
|
| -
|
| - PurseImpl(this._mint, this._balance) { }
|
| -
|
| - int queryBalance() {
|
| - return _balance;
|
| - }
|
| -
|
| - Purse sproutPurse() {
|
| - return _mint.createPurse(0);
|
| - }
|
| -
|
| - void deposit(int amount, Purse$Proxy purse) {
|
| - Purse$ProxyImpl impl = purse.dynamic;
|
| - PurseImpl source = impl.local;
|
| - if (source._balance < amount) throw "Not enough dough.";
|
| - _balance += amount;
|
| - source._balance -= amount;
|
| - }
|
| -
|
| - Mint _mint;
|
| - int _balance;
|
| -
|
| -}
|
| -
|
| -
|
| -class MintMakerPromiseTest {
|
| -
|
| - static void testMain() {
|
| - Mint$Proxy mint = createMint();
|
| - Purse$Proxy purse = mint.createPurse(100);
|
| - expectEquals(100, purse.queryBalance());
|
| -
|
| - Purse$Proxy sprouted = purse.sproutPurse();
|
| - expectEquals(0, sprouted.queryBalance());
|
| -
|
| - sprouted.deposit(5, purse);
|
| - expectEquals(0 + 5, sprouted.queryBalance());
|
| - expectEquals(100 - 5, purse.queryBalance());
|
| -
|
| - sprouted.deposit(42, purse);
|
| - expectEquals(0 + 5 + 42, sprouted.queryBalance());
|
| - expectEquals(100 - 5 - 42, purse.queryBalance());
|
| -
|
| - expectDone(6);
|
| - }
|
| -
|
| - static Mint$Proxy createMint() {
|
| - Proxy isolate = new Proxy.forIsolate(new Mint$Dispatcher$Isolate());
|
| - return new Mint$ProxyImpl(isolate);
|
| - }
|
| -
|
| -
|
| - static List<Promise> results;
|
| -
|
| - static void expectEquals(int expected, Promise<int> promise) {
|
| - if (results === null) {
|
| - results = new List<Promise>();
|
| - }
|
| - results.add(promise.then((int actual) {
|
| - Expect.equals(expected, actual);
|
| - }));
|
| - }
|
| -
|
| - static void expectDone(int n) {
|
| - if (results === null) {
|
| - Expect.equals(0, n);
|
| - } else {
|
| - Promise done = new Promise();
|
| - done.waitFor(results, results.length);
|
| - done.then((ignored) {
|
| - Expect.equals(n, results.length);
|
| - });
|
| - }
|
| - }
|
| -
|
| -}
|
| -
|
|
|
| // ---------------------------------------------------------------------------
|
| // THE REST OF THIS FILE COULD BE AUTOGENERATED
|
| // ---------------------------------------------------------------------------
|
|
|
| -interface Mint$Proxy {
|
| -
|
| - Purse$Proxy createPurse(int balance); // Promise<int> balance.
|
| -
|
| -}
|
| -
|
| -
|
| -class Mint$ProxyImpl extends ProxyImpl implements Mint$Proxy {
|
| -
|
| - Mint$ProxyImpl(Proxy isolate) : super.forReply(isolate.call([null])) {}
|
| -
|
| - Purse$Proxy createPurse(int balance) {
|
| - return new Purse$ProxyImpl(this.call([balance]));
|
| - }
|
| -
|
| -}
|
| -
|
| -
|
| -class Mint$Dispatcher extends Dispatcher<Mint> {
|
| -
|
| - Mint$Dispatcher(Mint mint) : super(mint) { }
|
| -
|
| - void process(var message, void reply(var response)) {
|
| - int balance = message[0];
|
| - Purse purse = target.createPurse(balance);
|
| - SendPort port = Dispatcher.serve(new Purse$Dispatcher(purse));
|
| - reply(port);
|
| - }
|
| -
|
| -}
|
| -
|
| -
|
| -class Mint$Dispatcher$Isolate extends Isolate {
|
| -
|
| - Mint$Dispatcher$Isolate() : super() { }
|
| -
|
| - void main() {
|
| - this.port.receive((var message, SendPort replyTo) {
|
| - Mint mint = new Mint();
|
| - SendPort port = Dispatcher.serve(new Mint$Dispatcher(mint));
|
| - Proxy proxy = new Proxy.forPort(replyTo);
|
| - proxy.send([port]);
|
| - });
|
| - }
|
| -
|
| -}
|
| -
|
| -
|
| -interface Purse$Proxy {
|
| -
|
| - Promise<int> queryBalance();
|
| - Purse$Proxy sproutPurse();
|
| - void deposit(int amount, Purse$Proxy source); // Promise<int> amount.
|
| -
|
| -}
|
| -
|
| -
|
| -class Purse$ProxyImpl extends ProxyImpl implements Purse$Proxy {
|
| -
|
| - Purse$ProxyImpl(Promise<SendPort> port) : super.forReply(port) { }
|
| -
|
| - Promise<int> queryBalance() {
|
| - return this.call(["balance"]);
|
| - }
|
| -
|
| - void deposit(int amount, Purse$Proxy source) {
|
| - this.send(["deposit", amount, source]);
|
| - }
|
| -
|
| - Purse$Proxy sproutPurse() {
|
| - return new Purse$ProxyImpl(this.call(["sprout"]));
|
| - }
|
| -
|
| -}
|
| -
|
| -
|
| -class Purse$Dispatcher extends Dispatcher<Purse> {
|
| -
|
| - Purse$Dispatcher(Purse purse) : super(purse) { }
|
| -
|
| - void process(var message, void reply(var response)) {
|
| - String command = message[0];
|
| - if (command == "balance") {
|
| - int balance = target.queryBalance();
|
| - reply(balance);
|
| - } else if (command == "deposit") {
|
| - int amount = message[1];
|
| - Promise<SendPort> port = new Promise<SendPort>.fromValue(message[2]);
|
| - Purse$Proxy source = new Purse$ProxyImpl(port);
|
| - target.deposit(amount, source);
|
| - } else if (command == "sprout") {
|
| - Purse purse = target.sproutPurse();
|
| - SendPort port = Dispatcher.serve(new Purse$Dispatcher(purse));
|
| - reply(port);
|
| - } else {
|
| - // TODO: Send an exception back.
|
| - reply("Exception: Command not understood");
|
| - }
|
| - }
|
| -
|
| -}
|
| -
|
|
|
| // ImportOptions=IsolateTestFramework
|
|
|
| @@ -1565,7 +1356,6 @@ class IsolateTest {
|
| IsolateTestFramework.waitForDone();
|
| RequestReplyTest.test();
|
| CountTest.test();
|
| - PromiseBasedTest.test();
|
| StaticStateTest.test();
|
| }
|
|
|
| @@ -1716,49 +1506,6 @@ class CountIsolate extends Isolate {
|
| }
|
|
|
|
|
| -// ---------------------------------------------------------------------------
|
| -// Promise-based test.
|
| -// ---------------------------------------------------------------------------
|
| -
|
| -class PromiseBasedTest {
|
| -
|
| - static void test() {
|
| - IsolateTest.waitForDone();
|
| - Proxy proxy = new Proxy.forIsolate(new PromiseIsolate());
|
| - proxy.send([42]); // Seed the isolate.
|
| - proxy.call([87]).then((int value) {
|
| - Expect.equals(42 + 87, value);
|
| - return 99;
|
| - }).then((int value) {
|
| - Expect.equals(99, value);
|
| - IsolateTest.done();
|
| - });
|
| - }
|
| -
|
| -}
|
| -
|
| -
|
| -class PromiseIsolate extends Isolate {
|
| -
|
| - PromiseIsolate() : super() { }
|
| -
|
| - void main() {
|
| - int seed = 0;
|
| - this.port.receive((var message, SendPort replyTo) {
|
| - if (seed == 0) {
|
| - seed = message[0];
|
| - } else {
|
| - Promise<int> response = new Promise<int>();
|
| - var proxy = new Proxy.forPort(replyTo);
|
| - proxy.send([response]);
|
| - response.complete(seed + message[0]);
|
| - this.port.close();
|
| - }
|
| - });
|
| - }
|
| -
|
| -}
|
| -
|
|
|
| // ---------------------------------------------------------------------------
|
| // State state test.
|
| @@ -2125,7 +1872,7 @@ class LineProcessorClient {
|
|
|
| MandelbrotState _state;
|
| int _id;
|
| - Promise<SendPort> _out;
|
| + Future<SendPort> _out;
|
|
|
| }
|
|
|
|
|