Index: tests/isolate/issue_21398_parent_isolate2_test.dart |
=================================================================== |
--- tests/isolate/issue_21398_parent_isolate2_test.dart (revision 0) |
+++ tests/isolate/issue_21398_parent_isolate2_test.dart (working copy) |
@@ -0,0 +1,50 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+import 'dart:isolate'; |
+import 'dart:async'; |
+import "package:expect/expect.dart"; |
+ |
+import "deferred_loaded_lib.dart" deferred as lib; |
+ |
+// 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.
|
+// that is loaded in the child isolate but not the parent isolate. The |
+// parent isolate does not know about the type of this object and throws |
+// an unhandled exception. |
+funcChild(args) { |
+ var replyPort = args[0]; |
+ // Defer load a library, create an object from that library and send |
+ // it over to the parent isolate which has not yet defer loaded that |
+ // library. |
+ lib.loadLibrary().then((_) { |
+ replyPort.send(new lib.FromChildIsolate()); |
+ }); |
+} |
+ |
+void helperFunction() { |
+ var receivePort = new ReceivePort(); |
+ |
+ // Spawn an isolate using spawnFunction. |
+ Isolate.spawn(funcChild, [receivePort.sendPort]).then( |
+ (isolate) { |
+ receivePort.listen( |
+ (msg) { |
+ // We don't expect to receive any valid messages. |
+ 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.
|
+ receivePort.close(); |
+ }, |
+ onError: (e) { |
+ // We don't expect to receive any error messages, per spec listen |
+ // does not receive an error object. |
+ Expect.equals(1, 0); |
+ receivePort.close(); |
+ } |
+ ); |
+ } |
+ ); |
+} |
+ |
+main() { |
+ helperFunction(); /// 01: runtime error |
+} |