| Index: tests/json/json_test.dart
|
| diff --git a/tests/json/json_test.dart b/tests/json/json_test.dart
|
| index 91965c3878a51ebd27696afce8f818db1f27db3f..649deba157f72457062aff506f9c48255908b32d 100644
|
| --- a/tests/json/json_test.dart
|
| +++ b/tests/json/json_test.dart
|
| @@ -53,7 +53,7 @@ main() {
|
|
|
| expect(JSON.parse('{ " hi bob " :3, "": 4.5}'),
|
| equals({ " hi bob " :3, "": 4.5}));
|
| -
|
| +
|
| expect(JSON.parse(' { "x" : { } } '), equals({ 'x' : {}}));
|
| expect(JSON.parse('{"x":{}}'), equals({ 'x' : {}}));
|
|
|
| @@ -112,6 +112,20 @@ main() {
|
| validateRoundTrip(
|
| {'x':{'a':3, 'b':-4.5}, 'y':[{}], 'z':'hi', 'w':{'c':null, 'd':true},
|
| 'v':null});
|
| +
|
| + expect(JSON.stringify(new ToJson(4)), "4");
|
| + expect(JSON.stringify(new ToJson([4, "a"])), '[4,"a"]');
|
| + expect(JSON.stringify(new ToJson([4, new ToJson({"x":42})])),
|
| + '[4,{"x":42}]');
|
| +
|
| + Expect.throws(() {
|
| + JSON.stringify([new ToJson(new ToJson(4))]);
|
| + });
|
| +
|
| + Expect.throws(() {
|
| + JSON.stringify([new Object()]);
|
| + });
|
| +
|
| });
|
|
|
| test('stringify throws if argument cannot be converted', () {
|
| @@ -131,6 +145,12 @@ class TestClass {
|
| TestClass() : x = 3, y = 'joe' { }
|
| }
|
|
|
| +class ToJson {
|
| + final object;
|
| + const ToJson(this.object);
|
| + toJson() => object;
|
| +}
|
| +
|
| /**
|
| * Checks that the argument can be converted to a JSON string and
|
| * back, and produce something equivalent to the argument.
|
|
|