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

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

Issue 11301046: Restructure pkg/unittest and pkg/webdriver to follow the pub conventions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/isolate/message2_test.dart ('k') | tests/isolate/mint_maker_test.dart » ('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) 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 // Dart test program for testing serialization of messages. 5 // Dart test program for testing serialization of messages.
6 // VMOptions=--enable_type_checks --enable_asserts 6 // VMOptions=--enable_type_checks --enable_asserts
7 7
8 #library('MessageTest'); 8 library MessageTest;
9 #import("dart:isolate"); 9 import 'dart:isolate';
10 #import('../../pkg/unittest/unittest.dart'); 10 import '../../pkg/unittest/lib/unittest.dart';
11 11
12 // --------------------------------------------------------------------------- 12 // ---------------------------------------------------------------------------
13 // Message passing test. 13 // Message passing test.
14 // --------------------------------------------------------------------------- 14 // ---------------------------------------------------------------------------
15 15
16 class MessageTest { 16 class MessageTest {
17 static const List list1 = const ["Hello", "World", "Hello", 0xfffffffffff]; 17 static const List list1 = const ["Hello", "World", "Hello", 0xfffffffffff];
18 static const List list2 = const [null, list1, list1, list1, list1]; 18 static const List list2 = const [null, list1, list1, list1, list1];
19 static const List list3 = const [list2, 2.0, true, false, 0xfffffffffff]; 19 static const List list3 = const [list2, 2.0, true, false, 0xfffffffffff];
20 static const Map map1 = const { 20 static const Map map1 = const {
21 "a=1" : 1, "b=2" : 2, "c=3" : 3, 21 "a=1" : 1, "b=2" : 2, "c=3" : 3,
22 }; 22 };
23 static const Map map2 = const { 23 static const Map map2 = const {
24 "list1" : list1, "list2" : list2, "list3" : list3, 24 "list1" : list1, "list2" : list2, "list3" : list3,
25 }; 25 };
26 static const List list4 = const [map1, map2]; 26 static const List list4 = const [map1, map2];
27 static const List elms = const [ 27 static const List elms = const [
28 list1, list2, list3, list4, 28 list1, list2, list3, list4,
29 ]; 29 ];
30 30
31 static void VerifyMap(Map expected, Map actual) { 31 static void VerifyMap(Map expected, Map actual) {
32 Expect.equals(true, expected is Map); 32 expect(expected, isMap);
33 Expect.equals(true, actual is Map); 33 expect(actual, isMap);
34 Expect.equals(expected.length, actual.length); 34 expect(actual.length, expected.length);
35 testForEachMap(key, value) { 35 testForEachMap(key, value) {
36 if (value is List) { 36 if (value is List) {
37 VerifyList(value, actual[key]); 37 VerifyList(value, actual[key]);
38 } else { 38 } else {
39 Expect.equals(value, actual[key]); 39 expect(actual[key], value);
40 } 40 }
41 } 41 }
42 expected.forEach(testForEachMap); 42 expected.forEach(testForEachMap);
43 } 43 }
44 44
45 static void VerifyList(List expected, List actual) { 45 static void VerifyList(List expected, List actual) {
46 for (int i = 0; i < expected.length; i++) { 46 for (int i = 0; i < expected.length; i++) {
47 if (expected[i] is List) { 47 if (expected[i] is List) {
48 VerifyList(expected[i], actual[i]); 48 VerifyList(expected[i], actual[i]);
49 } else if (expected[i] is Map) { 49 } else if (expected[i] is Map) {
50 VerifyMap(expected[i], actual[i]); 50 VerifyMap(expected[i], actual[i]);
51 } else { 51 } else {
52 Expect.equals(expected[i], actual[i]); 52 expect(actual[i], expected[i]);
53 } 53 }
54 } 54 }
55 } 55 }
56 56
57 static void VerifyObject(int index, var actual) { 57 static void VerifyObject(int index, var actual) {
58 var expected = elms[index]; 58 var expected = elms[index];
59 Expect.equals(true, expected is List); 59 expect(expected, isList);
60 Expect.equals(true, actual is List); 60 expect(actual, isList);
61 Expect.equals(expected.length, actual.length); 61 expect(actual.length, expected.length);
62 VerifyList(expected, actual); 62 VerifyList(expected, actual);
63 } 63 }
64 } 64 }
65 65
66 pingPong() { 66 pingPong() {
67 int count = 0; 67 int count = 0;
68 port.receive((var message, SendPort replyTo) { 68 port.receive((var message, SendPort replyTo) {
69 if (message == -1) { 69 if (message == -1) {
70 port.close(); 70 port.close();
71 replyTo.send(count, null); 71 replyTo.send(count, null);
(...skipping 28 matching lines...) Expand all
100 List local_list1 = ["Hello", "World", "Hello", 0xffffffffff]; 100 List local_list1 = ["Hello", "World", "Hello", 0xffffffffff];
101 List local_list2 = [null, local_list1, local_list1 ]; 101 List local_list2 = [null, local_list1, local_list1 ];
102 List local_list3 = [local_list2, 2.0, true, false, 0xffffffffff]; 102 List local_list3 = [local_list2, 2.0, true, false, 0xffffffffff];
103 List sendObject = new List(5); 103 List sendObject = new List(5);
104 sendObject[0] = local_list1; 104 sendObject[0] = local_list1;
105 sendObject[1] = sendObject; 105 sendObject[1] = sendObject;
106 sendObject[2] = local_list2; 106 sendObject[2] = local_list2;
107 sendObject[3] = sendObject; 107 sendObject[3] = sendObject;
108 sendObject[4] = local_list3; 108 sendObject[4] = local_list3;
109 remote.call(sendObject).then((var replyObject) { 109 remote.call(sendObject).then((var replyObject) {
110 Expect.equals(true, sendObject is List); 110 expect(sendObject, isList);
111 Expect.equals(true, replyObject is List); 111 expect(replyObject, isList);
112 Expect.equals(sendObject.length, replyObject.length); 112 expect(sendObject.length, equals(replyObject.length));
113 Expect.equals(true, replyObject[1] === replyObject); 113 expect(replyObject[1], same(replyObject));
114 Expect.equals(true, replyObject[3] === replyObject); 114 expect(replyObject[3], same(replyObject));
115 Expect.equals(true, replyObject[0] === replyObject[2][1]); 115 expect(replyObject[0], same(replyObject[2][1]));
116 Expect.equals(true, replyObject[0] === replyObject[2][2]); 116 expect(replyObject[0], same(replyObject[2][2]));
117 Expect.equals(true, replyObject[2] === replyObject[4][0]); 117 expect(replyObject[2], same(replyObject[4][0]));
118 Expect.equals(true, replyObject[0][0] === replyObject[0][2]); 118 expect(replyObject[0][0], same(replyObject[0][2]));
119 // Bigint literals are not canonicalized so do a == check. 119 // Bigint literals are not canonicalized so do a == check.
120 Expect.equals(true, replyObject[0][3] == replyObject[4][4]); 120 expect(replyObject[0][3], equals(replyObject[4][4]));
121 }); 121 });
122 122
123 // Shutdown the MessageServer. 123 // Shutdown the MessageServer.
124 remote.call(-1).then(expectAsync1((int message) { 124 remote.call(-1).then(expectAsync1((int message) {
125 Expect.equals(MessageTest.elms.length + 1, message); 125 expect(message, MessageTest.elms.length + 1);
126 })); 126 }));
127 }); 127 });
128 } 128 }
OLDNEW
« no previous file with comments | « tests/isolate/message2_test.dart ('k') | tests/isolate/mint_maker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698