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

Side by Side Diff: tests/corelib/src/PortTest.dart

Issue 9422019: isolates refactor: this change introduces 'dart:isolate' as a library. This is a (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 8 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
« no previous file with comments | « tests/corelib/src/FuturesTest.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
(Empty)
1 // Copyright (c) 2011, 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 properties of ports.
6
7 class PortTest {
8
9 static void testMain() {
10 testHashCode();
11 testEquals();
12 testMap();
13 }
14
15 static void testHashCode() {
16 ReceivePort rp0 = new ReceivePort();
17 ReceivePort rp1 = new ReceivePort();
18 Expect.equals(rp0.toSendPort().hashCode(), rp0.toSendPort().hashCode());
19 Expect.equals(rp1.toSendPort().hashCode(), rp1.toSendPort().hashCode());
20 rp0.close();
21 rp1.close();
22 }
23
24 static void testEquals() {
25 ReceivePort rp0 = new ReceivePort();
26 ReceivePort rp1 = new ReceivePort();
27 Expect.equals(rp0.toSendPort(), rp0.toSendPort());
28 Expect.equals(rp1.toSendPort(), rp1.toSendPort());
29 Expect.equals(false, (rp0.toSendPort() == rp1.toSendPort()));
30 rp0.close();
31 rp1.close();
32 }
33
34 static void testMap() {
35 ReceivePort rp0 = new ReceivePort();
36 ReceivePort rp1 = new ReceivePort();
37 final map = new Map<SendPort, int>();
38 map[rp0.toSendPort()] = 42;
39 map[rp1.toSendPort()] = 87;
40 Expect.equals(42, map[rp0.toSendPort()]);
41 Expect.equals(87, map[rp1.toSendPort()]);
42
43 map[rp0.toSendPort()] = 99;
44 Expect.equals(99, map[rp0.toSendPort()]);
45 Expect.equals(87, map[rp1.toSendPort()]);
46
47 map.remove(rp0.toSendPort());
48 Expect.equals(false, map.containsKey(rp0.toSendPort()));
49 Expect.equals(87, map[rp1.toSendPort()]);
50
51 map.remove(rp1.toSendPort());
52 Expect.equals(false, map.containsKey(rp0.toSendPort()));
53 Expect.equals(false, map.containsKey(rp1.toSendPort()));
54
55 rp0.close();
56 rp1.close();
57 }
58
59 }
60
61 main() {
62 PortTest.testMain();
63 }
OLDNEW
« no previous file with comments | « tests/corelib/src/FuturesTest.dart ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698