Index: tests/json/json_test.dart |
diff --git a/tests/json/json_test.dart b/tests/json/json_test.dart |
index 891fef3ee79b1ff90ba096299fd30a988fefdbcd..3f6235782711b43ded0b73427686ad59e7ddc109 100644 |
--- a/tests/json/json_test.dart |
+++ b/tests/json/json_test.dart |
@@ -136,6 +136,18 @@ main() { |
*/ |
expect(() => JSON.encode(new TestClass()), throws); |
}); |
+ |
+ test('stringify custom converter', () { |
+ List l = [const C(0), const C(1)]; |
+ expect(JSON.encode(l, (x) => "C(${x.id})"), equals("[C(0),C(1)]")); |
+ expect(JSON.encode(l), equals("[C/0,C/1]")); |
+ }); |
+} |
+ |
+class C { |
+ final int id; |
+ const C(this.id); |
+ toJson() => "C/$id"; |
} |
class TestClass { |
@@ -158,5 +170,3 @@ class ToJson { |
validateRoundTrip(expected) { |
expect(JSON.decode(JSON.encode(expected)), equals(expected)); |
} |
- |
- |