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

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

Issue 2763823002: Move spaces from before comments to within comments (Closed)
Patch Set: Fix comments Created 3 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
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:async'; 9 import 'dart:async';
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // List must be fixed. 144 // List must be fixed.
145 Expect.throws(() => x.add(42)); 145 Expect.throws(() => x.add(42));
146 }); 146 });
147 147
148 List constList = const [1, 2]; 148 List constList = const [1, 2];
149 ping.send(constList); 149 ping.send(constList);
150 checks.add((x) { 150 checks.add((x) {
151 Expect.isTrue(x is List); 151 Expect.isTrue(x is List);
152 Expect.listEquals([1, 2], x); 152 Expect.listEquals([1, 2], x);
153 // Make sure the list is immutable. 153 // Make sure the list is immutable.
154 Expect.throws(() => x[0] = 0); /// constList: ok 154 Expect.throws(() => x[0] = 0); // /// constList: ok
155 // List must not be extendable. 155 // List must not be extendable.
156 Expect.throws(() => x.add(3)); 156 Expect.throws(() => x.add(3));
157 Expect.identical(x, constList); /// constList_identical: ok 157 Expect.identical(x, constList); // /// constList_identical: ok
158 }); 158 });
159 159
160 Uint8List uint8 = new Uint8List(2); 160 Uint8List uint8 = new Uint8List(2);
161 uint8[0] = 0; 161 uint8[0] = 0;
162 uint8[1] = 1; 162 uint8[1] = 1;
163 ping.send(uint8); 163 ping.send(uint8);
164 checks.add((x) { 164 checks.add((x) {
165 Expect.isTrue(x is Uint8List); 165 Expect.isTrue(x is Uint8List);
166 Expect.equals(2, x.length); 166 Expect.equals(2, x.length);
167 Expect.equals(0, x[0]); 167 Expect.equals(0, x[0]);
168 Expect.equals(1, x[1]); 168 Expect.equals(1, x[1]);
169 }); 169 });
170 170
171 Uint16List uint16 = new Uint16List(2); 171 Uint16List uint16 = new Uint16List(2);
172 uint16[0] = 0; 172 uint16[0] = 0;
173 uint16[1] = 1; 173 uint16[1] = 1;
174 ByteBuffer byteBuffer = uint16.buffer; 174 ByteBuffer byteBuffer = uint16.buffer;
175 ping.send(byteBuffer); /// byteBuffer: ok 175 ping.send(byteBuffer); // /// byteBuffer: ok
176 checks.add( /// byteBuffer: ok 176 checks.add( // /// byteBuffer: ok
177 (x) { 177 (x) {
178 Expect.isTrue(x is ByteBuffer); 178 Expect.isTrue(x is ByteBuffer);
179 Uint16List uint16View = new Uint16List.view(x); 179 Uint16List uint16View = new Uint16List.view(x);
180 Expect.equals(2, uint16View.length); 180 Expect.equals(2, uint16View.length);
181 Expect.equals(0, uint16View[0]); 181 Expect.equals(0, uint16View[0]);
182 Expect.equals(1, uint16View[1]); 182 Expect.equals(1, uint16View[1]);
183 } 183 }
184 ) /// byteBuffer: ok 184 ) // /// byteBuffer: ok
185 ; 185 ;
186 186
187 Int32x4List list32x4 = new Int32x4List(2); 187 Int32x4List list32x4 = new Int32x4List(2);
188 list32x4[0] = new Int32x4(1, 2, 3, 4); 188 list32x4[0] = new Int32x4(1, 2, 3, 4);
189 list32x4[1] = new Int32x4(5, 6, 7, 8); 189 list32x4[1] = new Int32x4(5, 6, 7, 8);
190 ping.send(list32x4); /// int32x4: ok 190 ping.send(list32x4); // /// int32x4: ok
191 checks.add( /// int32x4: ok 191 checks.add( // /// int32x4: ok
192 (x) { 192 (x) {
193 Expect.isTrue(x is Int32x4List); 193 Expect.isTrue(x is Int32x4List);
194 Expect.equals(2, x.length); 194 Expect.equals(2, x.length);
195 Int32x4 entry1 = x[0]; 195 Int32x4 entry1 = x[0];
196 Int32x4 entry2 = x[1]; 196 Int32x4 entry2 = x[1];
197 Expect.equals(1, entry1.x); 197 Expect.equals(1, entry1.x);
198 Expect.equals(2, entry1.y); 198 Expect.equals(2, entry1.y);
199 Expect.equals(3, entry1.z); 199 Expect.equals(3, entry1.z);
200 Expect.equals(4, entry1.w); 200 Expect.equals(4, entry1.w);
201 Expect.equals(5, entry2.x); 201 Expect.equals(5, entry2.x);
202 Expect.equals(6, entry2.y); 202 Expect.equals(6, entry2.y);
203 Expect.equals(7, entry2.z); 203 Expect.equals(7, entry2.z);
204 Expect.equals(8, entry2.w); 204 Expect.equals(8, entry2.w);
205 } 205 }
206 ) /// int32x4: ok 206 ) // /// int32x4: ok
207 ; 207 ;
208 208
209 ping.send({"foo": 499, "bar": 32}); 209 ping.send({"foo": 499, "bar": 32});
210 checks.add((x) { 210 checks.add((x) {
211 Expect.isTrue(x is LinkedHashMap); 211 Expect.isTrue(x is LinkedHashMap);
212 Expect.listEquals(["foo", "bar"], x.keys.toList()); 212 Expect.listEquals(["foo", "bar"], x.keys.toList());
213 Expect.listEquals([499, 32], x.values.toList()); 213 Expect.listEquals([499, 32], x.values.toList());
214 Expect.equals(499, x["foo"]); 214 Expect.equals(499, x["foo"]);
215 Expect.equals(32, x["bar"]); 215 Expect.equals(32, x["bar"]);
216 // Must be mutable. 216 // Must be mutable.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 Expect.equals(499, x["gee"]); 270 Expect.equals(499, x["gee"]);
271 }); 271 });
272 272
273 Map constMap = const {'foo': 499}; 273 Map constMap = const {'foo': 499};
274 ping.send(constMap); 274 ping.send(constMap);
275 checks.add((x) { 275 checks.add((x) {
276 Expect.isTrue(x is Map); 276 Expect.isTrue(x is Map);
277 print(x.length); 277 print(x.length);
278 Expect.equals(1, x.length); 278 Expect.equals(1, x.length);
279 Expect.equals(499, x['foo']); 279 Expect.equals(499, x['foo']);
280 Expect.identical(constMap, x); /// constMap: ok 280 Expect.identical(constMap, x); // /// constMap: ok
281 Expect.throws(() => constMap['bar'] = 42); 281 Expect.throws(() => constMap['bar'] = 42);
282 }); 282 });
283 283
284 ping.send(new A()); 284 ping.send(new A());
285 checks.add((x) { 285 checks.add((x) {
286 Expect.isTrue(x is A); 286 Expect.isTrue(x is A);
287 Expect.equals(499, x.field); 287 Expect.equals(499, x.field);
288 }); 288 });
289 289
290 ping.send(new A.named(42)); 290 ping.send(new A.named(42));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 Expect.isTrue(x is C); 345 Expect.isTrue(x is C);
346 Expect.isTrue(x is D); 346 Expect.isTrue(x is D);
347 Expect.isTrue(x is M); 347 Expect.isTrue(x is M);
348 Expect.identical(x, x.field); 348 Expect.identical(x, x.field);
349 Expect.equals(11, x.field2); 349 Expect.equals(11, x.field2);
350 Expect.equals(499, x.superField); 350 Expect.equals(499, x.superField);
351 Expect.equals(99, x.superField2); 351 Expect.equals(99, x.superField2);
352 Expect.throws(() => x.field2 = 22); 352 Expect.throws(() => x.field2 = 22);
353 }); 353 });
354 354
355 ping.send(new E(E.fooFun)); /// fun: ok 355 ping.send(new E(E.fooFun)); // /// fun: ok
356 checks.add((x) { /// fun: continued 356 checks.add((x) { // /// fun: continued
357 Expect.equals(E.fooFun, x.fun); /// fun: continued 357 Expect.equals(E.fooFun, x.fun); // /// fun: continued
358 Expect.equals(499, x.fun()); /// fun: continued 358 Expect.equals(499, x.fun()); // /// fun: continued
359 }); /// fun: continued 359 }); // /// fun: continued
360 360
361 ping.send(new E(barFun)); /// fun: continued 361 ping.send(new E(barFun)); // /// fun: continued
362 checks.add((x) { /// fun: continued 362 checks.add((x) { // /// fun: continued
363 Expect.equals(barFun, x.fun); /// fun: continued 363 Expect.equals(barFun, x.fun); // /// fun: continued
364 Expect.equals(42, x.fun()); /// fun: continued 364 Expect.equals(42, x.fun()); // /// fun: continued
365 }); /// fun: continued 365 }); // /// fun: continued
366 366
367 Expect.throws(() => ping.send(new E(new E(null).instanceFun))); 367 Expect.throws(() => ping.send(new E(new E(null).instanceFun)));
368 368
369 F nonConstF = new F(); 369 F nonConstF = new F();
370 ping.send(nonConstF); 370 ping.send(nonConstF);
371 checks.add((x) { 371 checks.add((x) {
372 Expect.equals("field", x.field); 372 Expect.equals("field", x.field);
373 Expect.isFalse(identical(nonConstF, x)); 373 Expect.isFalse(identical(nonConstF, x));
374 }); 374 });
375 375
376 const F constF = const F(); 376 const F constF = const F();
377 ping.send(constF); 377 ping.send(constF);
378 checks.add((x) { 378 checks.add((x) {
379 Expect.equals("field", x.field); 379 Expect.equals("field", x.field);
380 Expect.identical(constF, x); /// constInstance: ok 380 Expect.identical(constF, x); // /// constInstance: ok
381 }); 381 });
382 382
383 G g1 = new G(nonConstF); 383 G g1 = new G(nonConstF);
384 G g2 = new G(constF); 384 G g2 = new G(constF);
385 G g3 = const G(constF); 385 G g3 = const G(constF);
386 ping.send(g1); 386 ping.send(g1);
387 ping.send(g2); 387 ping.send(g2);
388 ping.send(g3); 388 ping.send(g3);
389 389
390 checks.add((x) { // g1. 390 checks.add((x) { // g1.
391 Expect.isTrue(x is G); 391 Expect.isTrue(x is G);
392 Expect.isFalse(identical(g1, x)); 392 Expect.isFalse(identical(g1, x));
393 F f = x.field; 393 F f = x.field;
394 Expect.equals("field", f.field); 394 Expect.equals("field", f.field);
395 Expect.isFalse(identical(nonConstF, f)); 395 Expect.isFalse(identical(nonConstF, f));
396 }); 396 });
397 checks.add((x) { // g2. 397 checks.add((x) { // g2.
398 Expect.isTrue(x is G); 398 Expect.isTrue(x is G);
399 Expect.isFalse(identical(g1, x)); 399 Expect.isFalse(identical(g1, x));
400 F f = x.field; 400 F f = x.field;
401 Expect.equals("field", f.field); 401 Expect.equals("field", f.field);
402 Expect.identical(constF, f); /// constInstance: continued 402 Expect.identical(constF, f); // /// constInstance: continued
403 }); 403 });
404 checks.add((x) { // g3. 404 checks.add((x) { // g3.
405 Expect.isTrue(x is G); 405 Expect.isTrue(x is G);
406 Expect.identical(g3, x); /// constInstance: continued 406 Expect.identical(g3, x); // /// constInstance: continued
407 F f = x.field; 407 F f = x.field;
408 Expect.equals("field", f.field); 408 Expect.equals("field", f.field);
409 Expect.identical(constF, f); /// constInstance: continued 409 Expect.identical(constF, f); // /// constInstance: continued
410 }); 410 });
411 411
412 // Make sure objects in a map are serialized and deserialized in the correct 412 // Make sure objects in a map are serialized and deserialized in the correct
413 // order. 413 // order.
414 Map m = new Map(); 414 Map m = new Map();
415 Value val1 = new Value(1); 415 Value val1 = new Value(1);
416 Value val2 = new Value(2); 416 Value val2 = new Value(2);
417 m[val1] = val2; 417 m[val1] = val2;
418 m[val2] = val1; 418 m[val2] = val1;
419 // Possible bug we want to catch: 419 // Possible bug we want to catch:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 .spawn(echoMain, [initialReplyPort.sendPort, testPort.sendPort]) 453 .spawn(echoMain, [initialReplyPort.sendPort, testPort.sendPort])
454 .then((_) => initialReplyPort.first) 454 .then((_) => initialReplyPort.first)
455 .then((SendPort ping) { 455 .then((SendPort ping) {
456 runTests(ping, checks); 456 runTests(ping, checks);
457 Expect.isTrue(checks.length > 0); 457 Expect.isTrue(checks.length > 0);
458 completer.future 458 completer.future
459 .then((_) => ping.send("halt")) 459 .then((_) => ping.send("halt"))
460 .then((_) => asyncEnd()); 460 .then((_) => asyncEnd());
461 }); 461 });
462 } 462 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698