OLD | NEW |
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/lib/unittest.dart'; | 10 import '../../pkg/unittest/lib/unittest.dart'; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 var idx = i; | 93 var idx = i; |
94 remote.call(sentObject).then(expectAsync1((var receivedObject) { | 94 remote.call(sentObject).then(expectAsync1((var receivedObject) { |
95 MessageTest.VerifyObject(idx, receivedObject); | 95 MessageTest.VerifyObject(idx, receivedObject); |
96 })); | 96 })); |
97 } | 97 } |
98 | 98 |
99 // Send recursive objects and receive them back. | 99 // Send recursive objects and receive them back. |
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.fixedLength(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(sendObject, isList); | 110 expect(sendObject, isList); |
111 expect(replyObject, isList); | 111 expect(replyObject, isList); |
112 expect(sendObject.length, equals(replyObject.length)); | 112 expect(sendObject.length, equals(replyObject.length)); |
113 expect(replyObject[1], same(replyObject)); | 113 expect(replyObject[1], same(replyObject)); |
114 expect(replyObject[3], same(replyObject)); | 114 expect(replyObject[3], same(replyObject)); |
115 expect(replyObject[0], same(replyObject[2][1])); | 115 expect(replyObject[0], same(replyObject[2][1])); |
116 expect(replyObject[0], same(replyObject[2][2])); | 116 expect(replyObject[0], same(replyObject[2][2])); |
117 expect(replyObject[2], same(replyObject[4][0])); | 117 expect(replyObject[2], same(replyObject[4][0])); |
118 expect(replyObject[0][0], same(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(replyObject[0][3], equals(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(message, MessageTest.elms.length + 1); | 125 expect(message, MessageTest.elms.length + 1); |
126 })); | 126 })); |
127 }); | 127 }); |
128 } | 128 } |
OLD | NEW |