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

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

Issue 1294803003: Implement new parameters on Isolate.spawn() for dart2js. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Make tests succeed. Created 5 years, 4 months 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
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/isolate_patch.dart ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library exit_at_spawn; 5 library exit_at_spawn;
6 6
7 import "dart:isolate"; 7 import "dart:isolate";
8 import "dart:async"; 8 import "dart:async";
9 import "package:async_helper/async_helper.dart"; 9 import "package:async_helper/async_helper.dart";
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 11
12 // Isolate exiting immediately.
12 isomain(args) {} 13 isomain(args) {}
13 14
15 // Isolate exiting after running microtasks.
16 isomain2(args) {
17 scheduleMicrotask((){});
18 }
19
20 // Isolate exiting after running timers.
21 isomain3(args) {
22 new Timer(Duration.ZERO, (){});
23 }
24
14 main(){ 25 main(){
15 asyncStart(); 26 asyncStart();
16 27
28 test(isomain);
29 test(isomain2);
30 test(isomain3);
31
32 asyncEnd();
33 }
34
35 void test(mainFunction) {
36 asyncStart();
37
17 RawReceivePort exitPort = new RawReceivePort(); 38 RawReceivePort exitPort = new RawReceivePort();
18 exitPort.handler = (message) { 39 exitPort.handler = (message) {
19 Expect.equals(null, message); 40 Expect.equals(null, message);
20 exitPort.close(); 41 exitPort.close();
21 asyncEnd(); 42 asyncEnd();
22 }; 43 };
23 44
24 Isolate.spawn(isomain, 45 Isolate.spawn(mainFunction,
25 null, 46 null,
26 // Setup handler as part of spawn. 47 // Setup handler as part of spawn.
27 errorsAreFatal: false, 48 errorsAreFatal: false,
28 onExit: exitPort.sendPort); 49 onExit: exitPort.sendPort);
29 } 50 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/isolate_patch.dart ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698