OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /// Tests that Isolate.spawnUri completes with an error when the given URI |
| 6 /// doesn't resolve to an existing resource. |
| 7 /// |
| 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, |
| 10 /// these two situations are different. |
| 11 library test.isolate.spawn_uri_missing_from_isolate_test; |
| 12 |
| 13 import 'dart:isolate'; |
| 14 |
| 15 import 'dart:async'; |
| 16 |
| 17 import 'package:async_helper/async_helper.dart'; |
| 18 |
| 19 import 'spawn_uri_missing_test.dart'; |
| 20 |
| 21 const String SUCCESS = 'Test worked.'; |
| 22 |
| 23 void isolate(SendPort port) { |
| 24 doTest().then( |
| 25 (_) => port.send(SUCCESS), |
| 26 onError: (error, stack) => port.send('Test failed: $error\n$stack')); |
| 27 } |
| 28 |
| 29 main() { |
| 30 ReceivePort port = new ReceivePort(); |
| 31 Isolate.spawn(isolate, port.sendPort); |
| 32 Completer completer = new Completer(); |
| 33 port.listen((message) { |
| 34 if (message == SUCCESS) { |
| 35 completer.complete(null); |
| 36 } else { |
| 37 completer.completeError(message); |
| 38 } |
| 39 }); |
| 40 |
| 41 asyncTest(() => completer.future); |
| 42 } |
OLD | NEW |