| 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 library serialization_test; | 5 library serialization_test; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 import 'package:serialization/serialization.dart'; | 9 import 'package:serialization/serialization.dart'; |
| 10 import 'package:serialization/src/serialization_helpers.dart'; | 10 import 'package:serialization/src/serialization_helpers.dart'; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // but should we have some kind of large red flag that you're using private | 123 // but should we have some kind of large red flag that you're using private |
| 124 // state. | 124 // state. |
| 125 var stream = new Stream([3,4,5]); | 125 var stream = new Stream([3,4,5]); |
| 126 expect((stream..next()).next(), 4); | 126 expect((stream..next()).next(), 4); |
| 127 expect(stream.position, 2); | 127 expect(stream.position, 2); |
| 128 // The Symbol class does not allow us to create symbols for private | 128 // The Symbol class does not allow us to create symbols for private |
| 129 // variables. However, the mirror system uses them. So we get the symbol | 129 // variables. However, the mirror system uses them. So we get the symbol |
| 130 // we want from the mirror. | 130 // we want from the mirror. |
| 131 // TODO(alanknight): Either delete this test and decide we shouldn't | 131 // TODO(alanknight): Either delete this test and decide we shouldn't |
| 132 // attempt to access private variables or fix this properly. | 132 // attempt to access private variables or fix this properly. |
| 133 var _collectionSym = reflect(stream).type.variables.keys.firstWhere( | 133 var _collectionSym = reflect(stream).type.declarations.keys.firstWhere( |
| 134 (x) => MirrorSystem.getName(x) == "_collection"); | 134 (x) => MirrorSystem.getName(x) == "_collection"); |
| 135 var s = new Serialization() | 135 var s = new Serialization() |
| 136 ..addRuleFor(Stream, | 136 ..addRuleFor(Stream, |
| 137 constructorFields: [_collectionSym]); | 137 constructorFields: [_collectionSym]); |
| 138 var state = states(stream, s).first; | 138 var state = states(stream, s).first; |
| 139 // Define names for the variable offsets to make this more readable. | 139 // Define names for the variable offsets to make this more readable. |
| 140 var _collection = 0, position = 1; | 140 var _collection = 0, position = 1; |
| 141 expect(state[_collection],[3,4,5]); | 141 expect(state[_collection],[3,4,5]); |
| 142 expect(state[position], 2); | 142 expect(state[position], 2); |
| 143 }); | 143 }); |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 807 |
| 808 /** | 808 /** |
| 809 * Function used in an isolate to make sure that the output passes through | 809 * Function used in an isolate to make sure that the output passes through |
| 810 * isolate serialization properly. | 810 * isolate serialization properly. |
| 811 */ | 811 */ |
| 812 void echo(initialMessage) { | 812 void echo(initialMessage) { |
| 813 var msg = initialMessage[0]; | 813 var msg = initialMessage[0]; |
| 814 var reply = initialMessage[1]; | 814 var reply = initialMessage[1]; |
| 815 reply.send(msg); | 815 reply.send(msg); |
| 816 } | 816 } |
| OLD | NEW |