| OLD | NEW |
| 1 #library('IsolatesTest'); | 1 #library('IsolatesTest'); |
| 2 #import('../../lib/unittest/unittest.dart'); | 2 #import('../../lib/unittest/unittest.dart'); |
| 3 #import('../../lib/unittest/dom_config.dart'); | 3 #import('../../lib/unittest/dom_config.dart'); |
| 4 #import('dart:dom_deprecated'); | 4 #import('dart:dom_deprecated'); |
| 5 #import('dart:json'); | 5 #import('dart:json'); |
| 6 #import('dart:isolate', prefix:'isolate'); | 6 #import('dart:isolate', prefix:'isolate'); |
| 7 | 7 |
| 8 class PingPongIsolate extends isolate.Isolate { | 8 class PingPongIsolate extends isolate.Isolate { |
| 9 PingPongIsolate() : super.heavy(); | 9 PingPongIsolate() : super.heavy(); |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 port.receive((message, replyTo) { | 26 port.receive((message, replyTo) { |
| 27 replyTo.send(responseFor(message), null); | 27 replyTo.send(responseFor(message), null); |
| 28 }); | 28 }); |
| 29 } | 29 } |
| 30 | 30 |
| 31 static String responseFor(message) => 'response for $message'; | 31 static String responseFor(message) => 'response for $message'; |
| 32 } | 32 } |
| 33 | 33 |
| 34 main() { | 34 main() { |
| 35 useDomConfiguration(); | 35 useDomConfiguration(); |
| 36 asyncTest('IsolateSpawn', 1, () { | 36 test('IsolateSpawn', () { |
| 37 new PingPongIsolate().spawn().then((isolate.SendPort port) { | 37 new PingPongIsolate().spawn().then(expectAsync1((isolate.SendPort port) { |
| 38 callbackDone(); | 38 })); |
| 39 }); | |
| 40 }); | 39 }); |
| 41 asyncTest('NonDOMIsolates', 1, () { | 40 test('NonDOMIsolates', () { |
| 42 new PingPongIsolate().spawn().then((isolate.SendPort port) { | 41 new PingPongIsolate().spawn().then(expectAsync1((isolate.SendPort port) { |
| 43 final msg1 = 'foo'; | 42 final msg1 = 'foo'; |
| 44 final msg2 = 'bar'; | 43 final msg2 = 'bar'; |
| 45 port.call(msg1).then((response) { | 44 port.call(msg1).then(expectAsync1((response) { |
| 46 Expect.equals(PingPongIsolate.responseFor(msg1), response); | 45 Expect.equals(PingPongIsolate.responseFor(msg1), response); |
| 47 port.call(msg2).then((response) { | 46 port.call(msg2).then(expectAsync1((response) { |
| 48 Expect.equals(PingPongIsolate.responseFor(msg2), response); | 47 Expect.equals(PingPongIsolate.responseFor(msg2), response); |
| 49 callbackDone(); | 48 })); |
| 50 }); | 49 })); |
| 51 }); | 50 })); |
| 52 }); | |
| 53 }); | 51 }); |
| 54 } | 52 } |
| OLD | NEW |