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

Unified Diff: test/json_document_transformer_test.dart

Issue 1658833002: Be more explicit about JSON error handling. (Closed) Base URL: git@github.com:dart-lang/stream_channel.git@master
Patch Set: Code review changes Created 4 years, 11 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 | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/json_document_transformer_test.dart
diff --git a/test/json_document_transformer_test.dart b/test/json_document_transformer_test.dart
index fec3d2ac115aba52f3f452edaed1dbfe24bfab4f..65a3497245cbed111a38039fee00d235027e82c8 100644
--- a/test/json_document_transformer_test.dart
+++ b/test/json_document_transformer_test.dart
@@ -47,4 +47,16 @@ void main() {
transformed.sink.add(new Object());
expect(sinkController.stream.first, completion(equals('"encoded"')));
});
+
+ test("emits a stream error when incoming JSON is malformed", () {
+ var transformed = channel.transform(jsonDocument);
+ streamController.add("{invalid");
+ expect(transformed.stream.first, throwsFormatException);
+ });
+
+ test("synchronously throws if an unencodable object is added", () {
+ var transformed = channel.transform(jsonDocument);
+ expect(() => transformed.sink.add(new Object()),
+ throwsA(new isInstanceOf<JsonUnsupportedObjectError>()));
+ });
}
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698