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

Unified Diff: tests/lib/convert/json_toEncodable_reviver_test.dart

Issue 1153893004: In JsonEncoder, test if map has only string keys, and use toEncodable if not. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comment. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/convert/json.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/convert/json_toEncodable_reviver_test.dart
diff --git a/tests/lib/convert/json_toEncodable_reviver_test.dart b/tests/lib/convert/json_toEncodable_reviver_test.dart
index 58438875832ba8af0ec99feb114e2914d174648b..77ff1d4ac53ff2e3c98ce76b660461cfebabd7ad 100644
--- a/tests/lib/convert/json_toEncodable_reviver_test.dart
+++ b/tests/lib/convert/json_toEncodable_reviver_test.dart
@@ -38,4 +38,18 @@ main() {
var a = extendedJson.decode(extendedJson.encode(new A(499)));
Expect.isTrue(a is A);
Expect.equals(499, a.x);
+
+ testInvalidMap();
+}
+
+
+void testInvalidMap() {
+ var map = {"a" : 42, "b": 42, 37: 42}; // Non-string key.
+ var enc = new JsonEncoder((_) => "fixed");
+ var res = enc.convert(map);
+ Expect.equals('"fixed"', res);
+
+ enc = new JsonEncoder.withIndent(" ", (_) => "fixed");
+ res = enc.convert(map);
+ Expect.equals('"fixed"', res);
}
« no previous file with comments | « sdk/lib/convert/json.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698