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

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

Issue 14447008: Fix for mirror API breaking change to index libraries by URI, and clean up references in doc commen… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix from review Created 7 years, 8 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
« no previous file with comments | « pkg/serialization/lib/src/serialization_rule.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 data["person"] = new Person()..name = "Foo"; 510 data["person"] = new Person()..name = "Foo";
511 var output = s.write(data, new SimpleMapFormat()); 511 var output = s.write(data, new SimpleMapFormat());
512 var mapRule = s.rules.firstWhere((x) => x is MapRule); 512 var mapRule = s.rules.firstWhere((x) => x is MapRule);
513 var map = output["data"][mapRule.number][0]; 513 var map = output["data"][mapRule.number][0];
514 expect(map is Map, isTrue); 514 expect(map is Map, isTrue);
515 expect(map["abc"], 1); 515 expect(map["abc"], 1);
516 expect(map["def"], "ghi"); 516 expect(map["def"], "ghi");
517 expect(new Reader(s).asReference(map["person"]) is Reference, isTrue); 517 expect(new Reader(s).asReference(map["person"]) is Reference, isTrue);
518 }); 518 });
519 519
520 test("MirrorRule with lookup by qualified name rather than named object", () {
521 var s = new Serialization()..addRule(new MirrorRule());
522 var m = reflectClass(Address);
523 var output = s.write(m);
524 var input = s.read(output);
525 expect(input is ClassMirror, isTrue);
526 expect(MirrorSystem.getName(input.simpleName), "Address");
527 });
528
520 } 529 }
521 530
522 /****************************************************************************** 531 /******************************************************************************
523 * The end of the tests and the beginning of various helper functions to make 532 * The end of the tests and the beginning of various helper functions to make
524 * it easier to write the repetitive sections. 533 * it easier to write the repetitive sections.
525 ******************************************************************************/ 534 ******************************************************************************/
526 535
527 writeAndReadBack(Serialization s, Format format, object) { 536 writeAndReadBack(Serialization s, Format format, object) {
528 var w = s.newWriter(format); 537 var w = s.newWriter(format);
529 var output = w.write(object); 538 var output = w.write(object);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 ..children = map["children"] 660 ..children = map["children"]
652 ..parent = map["parent"]; 661 ..parent = map["parent"];
653 }); 662 });
654 return new Serialization() 663 return new Serialization()
655 ..selfDescribing = false 664 ..selfDescribing = false
656 ..addRule(rule); 665 ..addRule(rule);
657 } 666 }
658 667
659 /** 668 /**
660 * Run a round-trip test on a simple tree of nodes, using a serialization 669 * Run a round-trip test on a simple tree of nodes, using a serialization
661 * that's returned by the [serializerSetup] function. 670 * that's returned by the [serializerSetUp] function.
662 */ 671 */
663 runRoundTripTest(Function serializerSetUp) { 672 runRoundTripTest(Function serializerSetUp) {
664 Node n1 = new Node("1"), n2 = new Node("2"), n3 = new Node("3"); 673 Node n1 = new Node("1"), n2 = new Node("2"), n3 = new Node("3");
665 n1.children = [n2, n3]; 674 n1.children = [n2, n3];
666 n2.parent = n1; 675 n2.parent = n1;
667 n3.parent = n1; 676 n3.parent = n1;
668 var s = serializerSetUp(n1); 677 var s = serializerSetUp(n1);
669 var output = s.write(n2); 678 var output = s.write(n2);
670 var s2 = serializerSetUp(n1); 679 var s2 = serializerSetUp(n1);
671 var reader = new Reader(s2); 680 var reader = new Reader(s2);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 } 755 }
747 findValue(String key, Map state) { 756 findValue(String key, Map state) {
748 var answer; 757 var answer;
749 for (var each in state.keys) { 758 for (var each in state.keys) {
750 var value = state[each]; 759 var value = state[each];
751 if (value == key) return each; 760 if (value == key) return each;
752 } 761 }
753 return null; 762 return null;
754 } 763 }
755 } 764 }
OLDNEW
« no previous file with comments | « pkg/serialization/lib/src/serialization_rule.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698