| 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 Message2Test; | 8 library Message2Test; |
| 9 |
| 9 import 'dart:isolate'; | 10 import 'dart:isolate'; |
| 10 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 11 import "remote_unittest_helper.dart"; | 12 import "remote_unittest_helper.dart"; |
| 12 | 13 |
| 13 // --------------------------------------------------------------------------- | 14 // --------------------------------------------------------------------------- |
| 14 // Message passing test 2. | 15 // Message passing test 2. |
| 15 // --------------------------------------------------------------------------- | 16 // --------------------------------------------------------------------------- |
| 16 | 17 |
| 17 class MessageTest { | 18 class MessageTest { |
| 18 static void mapEqualsDeep(Map expected, Map actual) { | 19 static void mapEqualsDeep(Map expected, Map actual) { |
| 19 expect(expected, isMap); | 20 expect(expected, isMap); |
| 20 expect(actual, isMap); | 21 expect(actual, isMap); |
| 21 expect(actual.length, expected.length); | 22 expect(actual.length, expected.length); |
| 22 testForEachMap(key, value) { | 23 testForEachMap(key, value) { |
| 23 if (value is List) { | 24 if (value is List) { |
| 24 listEqualsDeep(value, actual[key]); | 25 listEqualsDeep(value, actual[key]); |
| 25 } else { | 26 } else { |
| 26 expect(actual[key], value); | 27 expect(actual[key], value); |
| 27 } | 28 } |
| 28 } | 29 } |
| 30 |
| 29 expected.forEach(testForEachMap); | 31 expected.forEach(testForEachMap); |
| 30 } | 32 } |
| 31 | 33 |
| 32 static void listEqualsDeep(List expected, List actual) { | 34 static void listEqualsDeep(List expected, List actual) { |
| 33 for (int i = 0; i < expected.length; i++) { | 35 for (int i = 0; i < expected.length; i++) { |
| 34 if (expected[i] is List) { | 36 if (expected[i] is List) { |
| 35 listEqualsDeep(expected[i], actual[i]); | 37 listEqualsDeep(expected[i], actual[i]); |
| 36 } else if (expected[i] is Map) { | 38 } else if (expected[i] is Map) { |
| 37 mapEqualsDeep(expected[i], actual[i]); | 39 mapEqualsDeep(expected[i], actual[i]); |
| 38 } else { | 40 } else { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 69 m[4] = "four"; | 71 m[4] = "four"; |
| 70 ReceivePort replyPort = new ReceivePort(); | 72 ReceivePort replyPort = new ReceivePort(); |
| 71 remote.send([m, replyPort.sendPort]); | 73 remote.send([m, replyPort.sendPort]); |
| 72 replyPort.first.then(expectAsync((var received) { | 74 replyPort.first.then(expectAsync((var received) { |
| 73 MessageTest.mapEqualsDeep(m, received); | 75 MessageTest.mapEqualsDeep(m, received); |
| 74 remote.send(null); | 76 remote.send(null); |
| 75 })); | 77 })); |
| 76 })); | 78 })); |
| 77 }); | 79 }); |
| 78 } | 80 } |
| OLD | NEW |