| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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("StaticStateTest"); | 5 #library("StaticStateTest"); |
| 6 #import("dart:isolate"); | 6 #import("dart:isolate"); |
| 7 #import("TestFramework.dart"); | 7 #import("TestFramework.dart"); |
| 8 | 8 |
| 9 class TestIsolate extends Isolate { | 9 class TestIsolate extends Isolate { |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 static String state; | 25 static String state; |
| 26 | 26 |
| 27 } | 27 } |
| 28 | 28 |
| 29 void test(TestExpectation expect) { | 29 void test(TestExpectation expect) { |
| 30 Expect.equals(null, TestIsolate.state); | 30 Expect.equals(null, TestIsolate.state); |
| 31 TestIsolate.state = "foo"; | 31 TestIsolate.state = "foo"; |
| 32 Expect.equals("foo", TestIsolate.state); | 32 Expect.equals("foo", TestIsolate.state); |
| 33 | 33 |
| 34 expect.completes(new TestIsolate().spawn()).then((SendPort remote) { | 34 expect.completes(new TestIsolate().spawn()).then((SendPort remote) { |
| 35 remote.call("bar").receive(expect.runs2((reply, replyTo) { | 35 remote.call("bar").then(expect.runs1((reply) { |
| 36 Expect.equals("foo", TestIsolate.state); | 36 Expect.equals("foo", TestIsolate.state); |
| 37 Expect.equals(null, reply); | 37 Expect.equals(null, reply); |
| 38 | 38 |
| 39 TestIsolate.state = "baz"; | 39 TestIsolate.state = "baz"; |
| 40 remote.call("exit").receive(expect.runs2((reply, replyTo) { | 40 remote.call("exit").then(expect.runs1((reply) { |
| 41 Expect.equals("baz", TestIsolate.state); | 41 Expect.equals("baz", TestIsolate.state); |
| 42 Expect.equals("bar", reply); | 42 Expect.equals("bar", reply); |
| 43 expect.succeeded(); | 43 expect.succeeded(); |
| 44 })); | 44 })); |
| 45 })); | 45 })); |
| 46 }); | 46 }); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void main() { | 49 void main() { |
| 50 runTests([test]); | 50 runTests([test]); |
| 51 } | 51 } |
| OLD | NEW |