OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015, 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 import 'dart:isolate'; | |
6 import 'dart:async'; | |
7 import "package:expect/expect.dart"; | |
8 | |
9 import "deferred_loaded_lib.dart" deferred as lib; | |
10 | |
11 // In this test case we send an object created from a defer loaded library | |
hausner
2015/02/13 18:05:49
So far we've used the term "deferred library" for
siva
2015/02/13 18:43:41
Done.
| |
12 // that is loaded in the child isolate but not the parent isolate. The | |
13 // parent isolate does not know about the type of this object and throws | |
14 // an unhandled exception. | |
15 funcChild(args) { | |
16 var replyPort = args[0]; | |
17 // Defer load a library, create an object from that library and send | |
18 // it over to the parent isolate which has not yet defer loaded that | |
19 // library. | |
20 lib.loadLibrary().then((_) { | |
21 replyPort.send(new lib.FromChildIsolate()); | |
22 }); | |
23 } | |
24 | |
25 void helperFunction() { | |
26 var receivePort = new ReceivePort(); | |
27 | |
28 // Spawn an isolate using spawnFunction. | |
29 Isolate.spawn(funcChild, [receivePort.sendPort]).then( | |
30 (isolate) { | |
31 receivePort.listen( | |
32 (msg) { | |
33 // We don't expect to receive any valid messages. | |
34 Expect.equals(1, 0); | |
hausner
2015/02/13 18:05:49
Use Expect.fail("should not receive a valid messag
siva
2015/02/13 18:43:41
Done.
| |
35 receivePort.close(); | |
36 }, | |
37 onError: (e) { | |
38 // We don't expect to receive any error messages, per spec listen | |
39 // does not receive an error object. | |
40 Expect.equals(1, 0); | |
41 receivePort.close(); | |
42 } | |
43 ); | |
44 } | |
45 ); | |
46 } | |
47 | |
48 main() { | |
49 helperFunction(); /// 01: runtime error | |
50 } | |
OLD | NEW |