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

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

Issue 11770004: Rename Date to DateTime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch 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
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 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:serialization/serialization.dart'; 8 import 'package:serialization/serialization.dart';
9 import 'package:serialization/src/serialization_helpers.dart'; 9 import 'package:serialization/src/serialization_helpers.dart';
10 import 'package:serialization/src/mirrors_helpers.dart'; 10 import 'package:serialization/src/mirrors_helpers.dart';
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 ..addRuleFor(stream, 121 ..addRuleFor(stream,
122 constructorFields: ['_collection']); 122 constructorFields: ['_collection']);
123 var state = states(stream, s).first; 123 var state = states(stream, s).first;
124 // Define names for the variable offsets to make this more readable. 124 // Define names for the variable offsets to make this more readable.
125 var _collection = 0, position = 1; 125 var _collection = 0, position = 1;
126 expect(state[_collection],[3,4,5]); 126 expect(state[_collection],[3,4,5]);
127 expect(state[position], 2); 127 expect(state[position], 2);
128 }); 128 });
129 129
130 test('date', () { 130 test('date', () {
131 var date = new Date.now(); 131 var date = new DateTime.now();
132 var s = new Serialization() 132 var s = new Serialization()
133 ..addRuleFor(date, 133 ..addRuleFor(date,
134 constructorFields : ["year", "month", "day", "hour", "minute", 134 constructorFields : ["year", "month", "day", "hour", "minute",
135 "second", "millisecond", "isUtc"]) 135 "second", "millisecond", "isUtc"])
136 .configureForMaps(); 136 .configureForMaps();
137 var state = states(date, s).first; 137 var state = states(date, s).first;
138 expect(state["year"],date.year); 138 expect(state["year"],date.year);
139 expect(state["isUtc"],date.isUtc); 139 expect(state["isUtc"],date.isUtc);
140 expect(state["millisecond"], date.millisecond); 140 expect(state["millisecond"], date.millisecond);
141 }); 141 });
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698