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

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

Issue 10153005: unittest step 3 and 4: remove TestFramework.dart, make test.dart use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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) 2011, the Dart project authors. Please see the AUTHORS file 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 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 // Dart test program for testing properties of ports. 5 // Test properties of ports.
6 // Note: unittest.dart depends on ports, in particular on the behaviour tested
7 // here. To keep things simple, we don't use the unittest library here.
8
6 #library("PortTest"); 9 #library("PortTest");
10
7 #import("dart:isolate"); 11 #import("dart:isolate");
12 #import('../../../lib/unittest/unittest.dart');
8 13
9 class PortTest { 14 main() {
10 15 testHashCode();
11 static void testMain() { 16 testEquals();
12 testHashCode(); 17 testMap();
13 testEquals();
14 testMap();
15 }
16
17 static void testHashCode() {
18 ReceivePort rp0 = new ReceivePort();
19 ReceivePort rp1 = new ReceivePort();
20 Expect.equals(rp0.toSendPort().hashCode(), rp0.toSendPort().hashCode());
21 Expect.equals(rp1.toSendPort().hashCode(), rp1.toSendPort().hashCode());
22 rp0.close();
23 rp1.close();
24 }
25
26 static void testEquals() {
27 ReceivePort rp0 = new ReceivePort();
28 ReceivePort rp1 = new ReceivePort();
29 Expect.equals(rp0.toSendPort(), rp0.toSendPort());
30 Expect.equals(rp1.toSendPort(), rp1.toSendPort());
31 Expect.equals(false, (rp0.toSendPort() == rp1.toSendPort()));
32 rp0.close();
33 rp1.close();
34 }
35
36 static void testMap() {
37 ReceivePort rp0 = new ReceivePort();
38 ReceivePort rp1 = new ReceivePort();
39 final map = new Map<SendPort, int>();
40 map[rp0.toSendPort()] = 42;
41 map[rp1.toSendPort()] = 87;
42 Expect.equals(42, map[rp0.toSendPort()]);
43 Expect.equals(87, map[rp1.toSendPort()]);
44
45 map[rp0.toSendPort()] = 99;
46 Expect.equals(99, map[rp0.toSendPort()]);
47 Expect.equals(87, map[rp1.toSendPort()]);
48
49 map.remove(rp0.toSendPort());
50 Expect.equals(false, map.containsKey(rp0.toSendPort()));
51 Expect.equals(87, map[rp1.toSendPort()]);
52
53 map.remove(rp1.toSendPort());
54 Expect.equals(false, map.containsKey(rp0.toSendPort()));
55 Expect.equals(false, map.containsKey(rp1.toSendPort()));
56
57 rp0.close();
58 rp1.close();
59 }
60
61 } 18 }
62 19
63 main() { 20 void testHashCode() {
64 PortTest.testMain(); 21 ReceivePort rp0 = new ReceivePort();
22 ReceivePort rp1 = new ReceivePort();
23 Expect.equals(rp0.toSendPort().hashCode(), rp0.toSendPort().hashCode());
24 Expect.equals(rp1.toSendPort().hashCode(), rp1.toSendPort().hashCode());
25 rp0.close();
26 rp1.close();
65 } 27 }
28
29 void testEquals() {
30 ReceivePort rp0 = new ReceivePort();
31 ReceivePort rp1 = new ReceivePort();
32 Expect.equals(rp0.toSendPort(), rp0.toSendPort());
33 Expect.equals(rp1.toSendPort(), rp1.toSendPort());
34 Expect.equals(false, (rp0.toSendPort() == rp1.toSendPort()));
35 rp0.close();
36 rp1.close();
37 }
38
39 void testMap() {
40 ReceivePort rp0 = new ReceivePort();
41 ReceivePort rp1 = new ReceivePort();
42 final map = new Map<SendPort, int>();
43 map[rp0.toSendPort()] = 42;
44 map[rp1.toSendPort()] = 87;
45 Expect.equals(42, map[rp0.toSendPort()]);
46 Expect.equals(87, map[rp1.toSendPort()]);
47
48 map[rp0.toSendPort()] = 99;
49 Expect.equals(99, map[rp0.toSendPort()]);
50 Expect.equals(87, map[rp1.toSendPort()]);
51
52 map.remove(rp0.toSendPort());
53 Expect.equals(false, map.containsKey(rp0.toSendPort()));
54 Expect.equals(87, map[rp1.toSendPort()]);
55
56 map.remove(rp1.toSendPort());
57 Expect.equals(false, map.containsKey(rp0.toSendPort()));
58 Expect.equals(false, map.containsKey(rp1.toSendPort()));
59
60 rp0.close();
61 rp1.close();
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698