| 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 '../../unittest/lib/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import '../lib/serialization.dart'; | 8 import 'package:serialization/serialization.dart'; |
| 9 import '../lib/src/serialization_helpers.dart'; | 9 import 'package:serialization/src/serialization_helpers.dart'; |
| 10 import '../lib/src/mirrors_helpers.dart'; | 10 import 'package:serialization/src/mirrors_helpers.dart'; |
| 11 | 11 |
| 12 part 'test_models.dart'; | 12 part 'test_models.dart'; |
| 13 | 13 |
| 14 main() { | 14 main() { |
| 15 var p1 = new Person(); | 15 var p1 = new Person(); |
| 16 var a1 = new Address(); | 16 var a1 = new Address(); |
| 17 a1.street = 'N 34th'; | 17 a1.street = 'N 34th'; |
| 18 a1.city = 'Seattle'; | 18 a1.city = 'Seattle'; |
| 19 | 19 |
| 20 test('Basic extraction of a simple object', () { | 20 test('Basic extraction of a simple object', () { |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 /** A hard-coded rule for serializing Node instances. */ | 496 /** A hard-coded rule for serializing Node instances. */ |
| 497 class NodeRule extends CustomRule { | 497 class NodeRule extends CustomRule { |
| 498 bool appliesTo(instance, _) => instance is Node; | 498 bool appliesTo(instance, _) => instance is Node; |
| 499 getState(instance) => [instance.parent, instance.name, instance.children]; | 499 getState(instance) => [instance.parent, instance.name, instance.children]; |
| 500 create(state) => new Node(state[1]); | 500 create(state) => new Node(state[1]); |
| 501 setState(Node node, state) { | 501 setState(Node node, state) { |
| 502 node.parent = state[0]; | 502 node.parent = state[0]; |
| 503 node.children = state[2]; | 503 node.children = state[2]; |
| 504 } | 504 } |
| 505 } | 505 } |
| OLD | NEW |