| Index: tests/html/isolates_test.dart
|
| diff --git a/tests/html/isolates_test.dart b/tests/html/isolates_test.dart
|
| index fa6070b3f177027a3e82d5ec7f55ca4443527d25..6b2e6941646ac113480a791c58caaea999c6b383 100644
|
| --- a/tests/html/isolates_test.dart
|
| +++ b/tests/html/isolates_test.dart
|
| @@ -5,53 +5,45 @@
|
| #import('dart:json');
|
| #import('dart:isolate', prefix:'isolate');
|
|
|
| -class PingPongIsolate extends isolate.Isolate {
|
| - PingPongIsolate() : super.heavy();
|
| +String responseFor(message) => 'response for $message';
|
|
|
| - void main() {
|
| - bool wasThrown = false;
|
| - try {
|
| - window.alert('Test');
|
| - } catch(final e) {
|
| - wasThrown = true;
|
| - }
|
| - // If wasn't thrown, do not listen to messages to make test fail.
|
| - if (!wasThrown) {
|
| - return;
|
| - }
|
| -
|
| - // Check that JSON library was loaded to isolate.
|
| - JSON.stringify([1, 2, 3]);
|
| -
|
| - port.receive((message, replyTo) {
|
| - replyTo.send(responseFor(message), null);
|
| - });
|
| +void isolateEntry() {
|
| + bool wasThrown = false;
|
| + try {
|
| + window.alert('Test');
|
| + } catch(final e) {
|
| + wasThrown = true;
|
| }
|
| + // If wasn't thrown, do not listen to messages to make test fail.
|
| + if (!wasThrown) {
|
| + return;
|
| + }
|
| +
|
| + // Check that JSON library was loaded to isolate.
|
| + JSON.stringify([1, 2, 3]);
|
|
|
| - static String responseFor(message) => 'response for $message';
|
| + isolate.port.receive((message, replyTo) {
|
| + replyTo.send(responseFor(message), null);
|
| + });
|
| }
|
|
|
| main() {
|
| useHtmlConfiguration();
|
| test('IsolateSpawn', () {
|
| - new PingPongIsolate().spawn().then(expectAsync1((isolate.SendPort port) {
|
| - }));
|
| + isolate.spawnFunction(isolateEntry);
|
| });
|
| test('NonDOMIsolates', () {
|
| var callback = expectAsync0((){});
|
| - new PingPongIsolate().spawn().then((isolate.SendPort port) {
|
| + var port = isolate.spawnFunction(isolateEntry);
|
| + final msg1 = 'foo';
|
| + final msg2 = 'bar';
|
| + port.call(msg1).then((response) {
|
| guardAsync(() {
|
| - final msg1 = 'foo';
|
| - final msg2 = 'bar';
|
| - port.call(msg1).then((response) {
|
| + Expect.equals(responseFor(msg1), response);
|
| + port.call(msg2).then((response) {
|
| guardAsync(() {
|
| - Expect.equals(PingPongIsolate.responseFor(msg1), response);
|
| - port.call(msg2).then((response) {
|
| - guardAsync(() {
|
| - Expect.equals(PingPongIsolate.responseFor(msg2), response);
|
| - callback();
|
| - });
|
| - });
|
| + Expect.equals(responseFor(msg2), response);
|
| + callback();
|
| });
|
| });
|
| });
|
|
|