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

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

Issue 11664006: Make Map.keys/values Iterables. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Add TODO that map.keys should return a Set. Created 7 years, 11 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') | runtime/lib/immutable_map.dart » ('j') | 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 '../../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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 Node n1 = new Node("1"), n2 = new Node("2"), n3 = new Node("3"); 185 Node n1 = new Node("1"), n2 = new Node("2"), n3 = new Node("3");
186 n1.children = [n2, n3]; 186 n1.children = [n2, n3];
187 n2.parent = n1; 187 n2.parent = n1;
188 n3.parent = n1; 188 n3.parent = n1;
189 189
190 test('Trace a cyclical structure', () { 190 test('Trace a cyclical structure', () {
191 var s = new Serialization(); 191 var s = new Serialization();
192 var trace = new Trace(new Writer(s)); 192 var trace = new Trace(new Writer(s));
193 trace.writer.trace = trace; 193 trace.writer.trace = trace;
194 trace.trace(n1); 194 trace.trace(n1);
195 var all = trace.writer.references.keys; 195 var all = trace.writer.references.keys.toSet();
196 expect(all.length, 4); 196 expect(all.length, 4);
197 expect(all.contains(n1), isTrue); 197 expect(all.contains(n1), isTrue);
198 expect(all.contains(n2), isTrue); 198 expect(all.contains(n2), isTrue);
199 expect(all.contains(n3), isTrue); 199 expect(all.contains(n3), isTrue);
200 expect(all.contains(n1.children), isTrue); 200 expect(all.contains(n1.children), isTrue);
201 }); 201 });
202 202
203 test('Flatten references in a cyclical structure', () { 203 test('Flatten references in a cyclical structure', () {
204 var s = new Serialization(); 204 var s = new Serialization();
205 var w = new Writer(s); 205 var w = new Writer(s);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 /** A hard-coded rule for serializing Node instances. */ 481 /** A hard-coded rule for serializing Node instances. */
482 class NodeRule extends CustomRule { 482 class NodeRule extends CustomRule {
483 bool appliesTo(instance, _) => instance is Node; 483 bool appliesTo(instance, _) => instance is Node;
484 getState(instance) => [instance.parent, instance.name, instance.children]; 484 getState(instance) => [instance.parent, instance.name, instance.children];
485 create(state) => new Node(state[1]); 485 create(state) => new Node(state[1]);
486 setState(Node node, state) { 486 setState(Node node, state) {
487 node.parent = state[0]; 487 node.parent = state[0];
488 node.children = state[2]; 488 node.children = state[2];
489 } 489 }
490 } 490 }
OLDNEW
« no previous file with comments | « pkg/serialization/lib/src/serialization_rule.dart ('k') | runtime/lib/immutable_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698