Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: pkg/serialization/test/serialization_test.dart

Issue 12086062: Rename mappedBy to map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:json' as json; 7 import 'dart:json' as json;
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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 expect(m2.name, "2"); 629 expect(m2.name, "2");
630 expect(m3.name, "3"); 630 expect(m3.name, "3");
631 expect(m2.parent, m1); 631 expect(m2.parent, m1);
632 expect(m3.parent, m1); 632 expect(m3.parent, m1);
633 expect(m1.parent, isNull); 633 expect(m1.parent, isNull);
634 } 634 }
635 635
636 /** Extract the state from [object] using the rules in [s] and return it. */ 636 /** Extract the state from [object] using the rules in [s] and return it. */
637 states(object, Serialization s) { 637 states(object, Serialization s) {
638 var rules = s.rulesFor(object, null); 638 var rules = s.rulesFor(object, null);
639 return rules.mappedBy((x) => x.extractState(object, doNothing)).toList(); 639 return rules.map((x) => x.extractState(object, doNothing)).toList();
640 } 640 }
641 641
642 /** A hard-coded rule for serializing Node instances. */ 642 /** A hard-coded rule for serializing Node instances. */
643 class NodeRule extends CustomRule { 643 class NodeRule extends CustomRule {
644 bool appliesTo(instance, _) => instance.runtimeType == Node; 644 bool appliesTo(instance, _) => instance.runtimeType == Node;
645 getState(instance) => [instance.parent, instance.name, instance.children]; 645 getState(instance) => [instance.parent, instance.name, instance.children];
646 create(state) => new Node(state[1]); 646 create(state) => new Node(state[1]);
647 setState(Node node, state) { 647 setState(Node node, state) {
648 node.parent = state[0]; 648 node.parent = state[0];
649 node.children = state[2]; 649 node.children = state[2];
650 } 650 }
651 } 651 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698