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

Unified Diff: pkg/serialization/test/serialization_test.dart

Issue 11644030: Rename specialTreatmentFor, improve handling of constants as constructor parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed obsolete TODO Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/serialization/lib/src/mirrors_helpers.dart ('k') | pkg/serialization/test/test_models.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/serialization/test/serialization_test.dart
diff --git a/pkg/serialization/test/serialization_test.dart b/pkg/serialization/test/serialization_test.dart
index 1cdc3b01c1ad862a5fc600b23c2c502b432f7e18..6942a78b44049a80228018f6cea631d54b049a44 100644
--- a/pkg/serialization/test/serialization_test.dart
+++ b/pkg/serialization/test/serialization_test.dart
@@ -265,7 +265,7 @@ main() {
n3.parent = n1;
var s = new Serialization()
..addRuleFor(n1, constructorFields: ["name"]).
- specialTreatmentFor("children", (parent, child) =>
+ setFieldWith("children", (parent, child) =>
parent.reflectee.children = child);
var w = new Writer(s);
w.write(n1);
@@ -302,6 +302,21 @@ main() {
expect(identical(m2.parent, m3.parent), isTrue);
});
+ test("Constant values as fields", () {
+ var s = new Serialization()
+ ..selfDescribing = false
+ ..addRuleFor(a1,
+ constructor: 'with',
+ constructorFields: ["street", "Kirkland", "WA", "98103"],
+ fields: []);
+ var out = s.write(a1);
+ var newAddress = s.read(out);
+ expect(newAddress.street, a1.street);
+ expect(newAddress.city, "Kirkland");
+ expect(newAddress.state, "WA");
+ expect(newAddress.zip, "98103");
+ });
+
}
/******************************************************************************
@@ -326,7 +341,7 @@ Serialization metaSerialization() {
'constructorName',
'constructorFields', 'regularFields', []],
fields: [])
- ..addRuleFor(new Serialization()).specialTreatmentFor('rules',
+ ..addRuleFor(new Serialization()).setFieldWith('rules',
(InstanceMirror s, List rules) {
rules.forEach((x) => s.reflectee.addRule(x));
})
« no previous file with comments | « pkg/serialization/lib/src/mirrors_helpers.dart ('k') | pkg/serialization/test/test_models.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698