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

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

Issue 218273002: Upgrading tests with unittest deprecations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 illegal_msg_function_test; 5 library illegal_msg_function_test;
6 6
7 import "dart:isolate"; 7 import "dart:isolate";
8 import "dart:async" show Future; 8 import "dart:async" show Future;
9 import "package:unittest/unittest.dart"; 9 import "package:unittest/unittest.dart";
10 import "remote_unittest_helper.dart"; 10 import "remote_unittest_helper.dart";
11 11
12 funcFoo(x) => x + 2; 12 funcFoo(x) => x + 2;
13 13
14 echo(sendPort) { 14 echo(sendPort) {
15 var port = new ReceivePort(); 15 var port = new ReceivePort();
16 sendPort.send(port.sendPort); 16 sendPort.send(port.sendPort);
17 port.listen((msg) { 17 port.listen((msg) {
18 sendPort.send("echoing ${msg(1)}}"); 18 sendPort.send("echoing ${msg(1)}}");
19 }); 19 });
20 } 20 }
21 21
22 void main([args, port]) { 22 void main([args, port]) {
23 if (testRemote(main, port)) return; 23 if (testRemote(main, port)) return;
24 test("msg_function", () { 24 test("msg_function", () {
25 var function = funcFoo; 25 var function = funcFoo;
26 ReceivePort port = new ReceivePort(); 26 ReceivePort port = new ReceivePort();
27 Future spawn = Isolate.spawn(echo, port.sendPort); 27 Future spawn = Isolate.spawn(echo, port.sendPort);
28 var caught_exception = false; 28 var caught_exception = false;
29 var stream = port.asBroadcastStream(); 29 var stream = port.asBroadcastStream();
30 stream.first.then(expectAsync1((snd) { 30 stream.first.then(expectAsync((snd) {
31 try { 31 try {
32 snd.send(function); 32 snd.send(function);
33 } catch (e) { 33 } catch (e) {
34 caught_exception = true; 34 caught_exception = true;
35 } 35 }
36 36
37 if (caught_exception) { 37 if (caught_exception) {
38 port.close(); 38 port.close();
39 } else { 39 } else {
40 stream.first.then(expectAsync1((msg) { 40 stream.first.then(expectAsync((msg) {
41 print("from worker ${msg}"); 41 print("from worker ${msg}");
42 })); 42 }));
43 } 43 }
44 expect(caught_exception, isTrue); 44 expect(caught_exception, isTrue);
45 })); 45 }));
46 }); 46 });
47 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698