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

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

Issue 2989493002: Simplify and fix implicit closure check, speed up Closure_equals (Closed)
Patch Set: Created 3 years, 5 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
« runtime/vm/object.cc ('K') | « runtime/vm/source_report.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, 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 // Dart test program for testing serialization of messages with static
6 // native functions.
7
8 library MessageTest;
9
10 import 'dart:async';
11 import 'dart:collection';
12 import 'dart:isolate';
13 import 'package:async_helper/async_helper.dart';
zra 2017/07/21 19:54:16 package: imports should come after all dart: impor
alexmarkov 2017/07/21 20:51:42 Done.
14 import 'package:expect/expect.dart';
15 import 'dart:typed_data';
16
17 void echoMain(msg) {
18 SendPort replyTo = msg[0];
19 SendPort pong = msg[1];
20 ReceivePort port = new ReceivePort();
21 replyTo.send(port.sendPort);
22 port.listen((msg) {
23 if (msg == "halt") {
24 port.close();
25 } else {
26 pong.send(msg);
27 }
28 });
29 }
30
31 void runTests(SendPort ping, Queue checks) {
32 ping.send("abc");
33 checks.add((x) => Expect.equals("abc", x));
34
35 ping.send(int.parse);
36 checks.add((x) => Expect.identical(int.parse, x));
37
38 ping.send(identityHashCode);
39 checks.add((x) => Expect.identical(identityHashCode, x));
40
41 ping.send(identical);
42 checks.add((x) => Expect.identical(identical, x));
43 }
44
45 void main() {
46 asyncStart();
47 Queue checks = new Queue();
48 ReceivePort testPort = new ReceivePort();
49 Completer completer = new Completer();
50
51 testPort.listen((msg) {
52 Function check = checks.removeFirst();
53 check(msg);
54 if (checks.isEmpty) {
55 completer.complete();
56 testPort.close();
57 }
58 });
59
60 ReceivePort initialReplyPort = new ReceivePort();
61 Isolate
zra 2017/07/21 19:54:16 Maybe instead something like: main() async { ..
alexmarkov 2017/07/21 20:51:42 Done.
62 .spawn(echoMain, [initialReplyPort.sendPort, testPort.sendPort])
63 .then((_) => initialReplyPort.first)
64 .then((SendPort ping) {
65 runTests(ping, checks);
66 Expect.isTrue(checks.length > 0);
67 completer.future.then((_) => ping.send("halt")).then((_) => asyncEnd());
68 });
69 }
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/source_report.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698