Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: tests/isolate/issue_21398_parent_isolate_test.dart

Issue 1477043002: Fix tests that don't catch asynchronous errors from isolate spawning. Update co19 status. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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 // Note: the following comment is used by test.dart to additionally compile the 5 // Note: the following comment is used by test.dart to additionally compile the
6 // other isolate's code. 6 // other isolate's code.
7 // OtherScripts=issue_21398_child_isolate.dart 7 // OtherScripts=issue_21398_child_isolate.dart
8 8
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:async'; 10 import 'dart:async';
11 import "package:expect/expect.dart"; 11 import "package:expect/expect.dart";
12 import 'package:async_helper/async_helper.dart';
12 13
13 class FromMainIsolate { 14 class FromMainIsolate {
14 String toString() => 'from main isolate'; 15 String toString() => 'from main isolate';
15 int get fld => 10; 16 int get fld => 10;
16 } 17 }
17 18
18 funcChild(args) { 19 funcChild(args) {
19 var reply = args[1]; 20 var reply = args[1];
20 var obj = args[0]; 21 var obj = args[0];
21 Expect.isTrue(obj is FromMainIsolate); 22 Expect.isTrue(obj is FromMainIsolate);
22 Expect.equals(10, obj.fld); 23 Expect.equals(10, obj.fld);
23 reply.send(new FromMainIsolate()); 24 reply.send(new FromMainIsolate());
24 } 25 }
25 26
26 main() { 27 main() {
27 var receive1 = new ReceivePort(); 28 var receive1 = new ReceivePort();
28 var receive2 = new ReceivePort(); 29 var receive2 = new ReceivePort();
29 30
30 // First spawn an isolate using spawnURI and have it 31 // First spawn an isolate using spawnURI and have it
31 // send back a "non-literal" like object. 32 // send back a "non-literal" like object.
33 asyncStart();
32 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate.dart'), 34 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate.dart'),
33 [], 35 [],
34 [new FromMainIsolate(), receive1.sendPort]).catchError( 36 [new FromMainIsolate(), receive1.sendPort]).catchError(
35 (error) { 37 (error) {
36 Expect.isTrue(error is ArgumentError); 38 Expect.isTrue(error is ArgumentError);
39 asyncEnd();
37 } 40 }
38 ); 41 );
42 asyncStart();
39 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate.dart'), 43 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate.dart'),
40 [], 44 [],
41 receive1.sendPort).then( 45 receive1.sendPort).then(
42 (isolate) { 46 (isolate) {
43 receive1.listen( 47 receive1.listen(
44 (msg) { 48 (msg) {
45 Expect.stringEquals(msg, "Invalid Argument(s)."); 49 Expect.stringEquals(msg, "Invalid Argument(s).");
46 receive1.close(); 50 receive1.close();
51 asyncEnd();
47 }, 52 },
48 onError: (e) => print('$e') 53 onError: (e) => print('$e')
49 ); 54 );
50 } 55 }
51 ); 56 );
52 57
53 // Now spawn an isolate using spawnFunction and send it a "non-literal" 58 // Now spawn an isolate using spawnFunction and send it a "non-literal"
54 // like object and also have the child isolate send back a "non-literal" 59 // like object and also have the child isolate send back a "non-literal"
55 // like object. 60 // like object.
56 Isolate.spawn(funcChild, 61 asyncStart();
62 Isolate.spawn(funcChild,
57 [new FromMainIsolate(), receive2.sendPort]).then( 63 [new FromMainIsolate(), receive2.sendPort]).then(
58 (isolate) { 64 (isolate) {
59 receive2.listen( 65 receive2.listen(
60 (msg) { 66 (msg) {
61 Expect.isTrue(msg is FromMainIsolate); 67 Expect.isTrue(msg is FromMainIsolate);
62 Expect.equals(10, msg.fld); 68 Expect.equals(10, msg.fld);
63 receive2.close(); 69 receive2.close();
70 asyncEnd();
64 }, 71 },
65 onError: (e) => print('$e') 72 onError: (e) => print('$e')
66 ); 73 );
67 } 74 }
68 ); 75 );
69 } 76 }
OLDNEW
« no previous file with comments | « tests/isolate/issue_21398_parent_isolate2_test.dart ('k') | tests/isolate/message_enum_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698