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

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: 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
« sdk/lib/convert/json.dart ('K') | « 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..d3d507d45182fe5ade55013ef9a21f93dcad5f84 100644
--- a/tests/lib/convert/json_toEncodable_reviver_test.dart
+++ b/tests/lib/convert/json_toEncodable_reviver_test.dart
@@ -38,4 +38,14 @@ 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((x) => "fixed");
+ var res = enc.convert(map);
+ Expect.equals('"fixed"', res);
}
« sdk/lib/convert/json.dart ('K') | « sdk/lib/convert/json.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698