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 '../../unittest/lib/unittest.dart'; |
8 import '../lib/serialization.dart'; | 8 import '../lib/serialization.dart'; |
9 import '../lib/src/serialization_helpers.dart'; | 9 import '../lib/src/serialization_helpers.dart'; |
10 import '../lib/src/mirrors_helpers.dart'; | 10 import '../lib/src/mirrors_helpers.dart'; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 var closureRule = new ClosureToMapRule.stub([].runtimeType); | 308 var closureRule = new ClosureToMapRule.stub([].runtimeType); |
309 var basicRule = new BasicRule(reflect(null).type, '', [], [], []); | 309 var basicRule = new BasicRule(reflect(null).type, '', [], [], []); |
310 | 310 |
311 var meta = new Serialization() | 311 var meta = new Serialization() |
312 ..selfDescribing = false | 312 ..selfDescribing = false |
313 ..addRuleFor(new ListRule()) | 313 ..addRuleFor(new ListRule()) |
314 ..addRuleFor(new PrimitiveRule()) | 314 ..addRuleFor(new PrimitiveRule()) |
315 // TODO(alanknight): Handle the ClosureToMapRule as well. | 315 // TODO(alanknight): Handle the ClosureToMapRule as well. |
316 // Note that we're passing in a constant for one of the fields. | 316 // Note that we're passing in a constant for one of the fields. |
317 ..addRuleFor(basicRule, | 317 ..addRuleFor(basicRule, |
318 constructorFields: ['typeWrapped', | 318 constructorFields: ['type', |
319 'constructorName', | 319 'constructorName', |
320 'constructorFields', 'regularFields', []], | 320 'constructorFields', 'regularFields', []], |
321 fields: []) | 321 fields: []) |
322 ..addRuleFor(new Serialization()).specialTreatmentFor('rules', | 322 ..addRuleFor(new Serialization()).specialTreatmentFor('rules', |
323 (InstanceMirror s, List rules) { | 323 (InstanceMirror s, List rules) { |
324 rules.forEach((x) => s.reflectee.addRule(x)); | 324 rules.forEach((x) => s.reflectee.addRule(x)); |
325 }) | 325 }) |
326 ..addRule(new ClassMirrorRule()); | 326 ..addRule(new ClassMirrorRule()); |
327 return meta; | 327 return meta; |
328 } | 328 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 expect(m2.parent, m1); | 453 expect(m2.parent, m1); |
454 expect(m3.parent, m1); | 454 expect(m3.parent, m1); |
455 expect(m1.parent, isNull); | 455 expect(m1.parent, isNull); |
456 } | 456 } |
457 | 457 |
458 /** Extract the state from [object] using the rules in [s] and return it. */ | 458 /** Extract the state from [object] using the rules in [s] and return it. */ |
459 states(Object object, Serialization s) { | 459 states(Object object, Serialization s) { |
460 var rules = s.rulesFor(object); | 460 var rules = s.rulesFor(object); |
461 return rules.map((x) => x.extractState(object, doNothing)); | 461 return rules.map((x) => x.extractState(object, doNothing)); |
462 } | 462 } |
OLD | NEW |