| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Tests that Isolate.spawnUri completes with an error when the given URI | 5 /// Tests that Isolate.spawnUri completes with an error when the given URI |
| 6 /// doesn't resolve to an existing resource. | 6 /// doesn't resolve to an existing resource. |
| 7 /// | 7 /// |
| 8 /// This test is similar to spawn_uri_missing_test.dart, but tests what happens | 8 /// This test is similar to spawn_uri_missing_test.dart, but tests what happens |
| 9 /// when Isolate.spawnUri is called from an a spawned isolate. In dart2js, | 9 /// when Isolate.spawnUri is called from an a spawned isolate. In dart2js, |
| 10 /// these two situations are different. | 10 /// these two situations are different. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 void isolate(SendPort port) { | 23 void isolate(SendPort port) { |
| 24 doTest().then( | 24 doTest().then( |
| 25 (_) => port.send(SUCCESS), | 25 (_) => port.send(SUCCESS), |
| 26 onError: (error, stack) => port.send('Test failed: $error\n$stack')); | 26 onError: (error, stack) => port.send('Test failed: $error\n$stack')); |
| 27 } | 27 } |
| 28 | 28 |
| 29 main() { | 29 main() { |
| 30 ReceivePort port = new ReceivePort(); | 30 ReceivePort port = new ReceivePort(); |
| 31 Isolate.spawn(isolate, port.sendPort); | 31 Isolate.spawn(isolate, port.sendPort); |
| 32 Completer completer = new Completer(); | 32 Completer completer = new Completer(); |
| 33 port.listen((message) { | 33 port.first.then((message) { |
| 34 if (message == SUCCESS) { | 34 if (message == SUCCESS) { |
| 35 completer.complete(null); | 35 completer.complete(null); |
| 36 } else { | 36 } else { |
| 37 completer.completeError(message); | 37 completer.completeError(message); |
| 38 } | 38 } |
| 39 port.close(); | |
| 40 }); | 39 }); |
| 41 | 40 |
| 42 asyncTest(() => completer.future); | 41 asyncTest(() => completer.future); |
| 43 } | 42 } |
| OLD | NEW |