| OLD | NEW |
| 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 serialization of messages without spawning | 5 // Dart test program for testing serialization of messages without spawning |
| 6 // isolates. | 6 // isolates. |
| 7 | 7 |
| 8 // --------------------------------------------------------------------------- | 8 // --------------------------------------------------------------------------- |
| 9 // Serialization test. | 9 // Serialization test. |
| 10 // --------------------------------------------------------------------------- | 10 // --------------------------------------------------------------------------- |
| 11 #library('SerializationTest'); | 11 #library('SerializationTest'); |
| 12 #import("dart:coreimpl"); | 12 #import('dart:isolate'); |
| 13 | 13 |
| 14 main() { | 14 main() { |
| 15 testAllTypes(copy); | 15 // TODO(sigmund): fix once we can disable privacy for testing (bug #1882) |
| 16 testAllTypes(serialize); | 16 testAllTypes(TestingOnly.copy); |
| 17 } | 17 testAllTypes(TestingOnly.serialize); |
| 18 | |
| 19 copy(x) { | |
| 20 return new Copier().traverse(x); | |
| 21 } | |
| 22 | |
| 23 serialize(x) { | |
| 24 Serializer serializer = new Serializer(); | |
| 25 Deserializer deserializer = new Deserializer(); | |
| 26 return deserializer.deserialize(serializer.traverse(x)); | |
| 27 } | 18 } |
| 28 | 19 |
| 29 void testAllTypes(Function f) { | 20 void testAllTypes(Function f) { |
| 30 copyAndVerify(0, f); | 21 copyAndVerify(0, f); |
| 31 copyAndVerify(499, f); | 22 copyAndVerify(499, f); |
| 32 copyAndVerify(true, f); | 23 copyAndVerify(true, f); |
| 33 copyAndVerify(false, f); | 24 copyAndVerify(false, f); |
| 34 copyAndVerify("", f); | 25 copyAndVerify("", f); |
| 35 copyAndVerify("foo", f); | 26 copyAndVerify("foo", f); |
| 36 copyAndVerify([], f); | 27 copyAndVerify([], f); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 Expect.isTrue(copy is Map); | 74 Expect.isTrue(copy is Map); |
| 84 Expect.equals(o.length, copy.length); | 75 Expect.equals(o.length, copy.length); |
| 85 o.forEach((key, value) { | 76 o.forEach((key, value) { |
| 86 Expect.isTrue(copy.containsKey(key)); | 77 Expect.isTrue(copy.containsKey(key)); |
| 87 verify(value, copy[key]); | 78 verify(value, copy[key]); |
| 88 }); | 79 }); |
| 89 } else { | 80 } else { |
| 90 Expect.fail("Unexpected object encountered"); | 81 Expect.fail("Unexpected object encountered"); |
| 91 } | 82 } |
| 92 } | 83 } |
| OLD | NEW |