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

Unified Diff: runtime/vm/object_test.cc

Issue 206003005: Ensure PrintToJSONStream can be called on all heap objects without crashing. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object_test.cc
===================================================================
--- runtime/vm/object_test.cc (revision 34253)
+++ runtime/vm/object_test.cc (working copy)
@@ -4058,4 +4058,35 @@
EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString());
}
+
+class JSONTypeVerifier : public ObjectVisitor {
+ public:
+ JSONTypeVerifier() : ObjectVisitor(Isolate::Current()) {}
+ virtual ~JSONTypeVerifier() { }
+ virtual void VisitObject(RawObject* obj) {
+ // Free-list elements cannot even be wrapped in handles.
+ if (obj->IsFreeListElement()) {
+ return;
+ }
+ Object& handle = Object::Handle(obj);
+ // Skip some common simple objects to run in reasonable time.
+ if (handle.IsString() ||
+ handle.IsArray() ||
+ handle.IsLiteralToken()) {
+ return;
+ }
+ JSONStream js;
+ handle.PrintToJSONStream(&js, false);
+ // TODO(koda): When all objects include a "type" field, expect that here.
+ }
+};
+
+
+TEST_CASE(PrintToJSONStream) {
+ Heap* heap = Isolate::Current()->heap();
+ heap->CollectAllGarbage();
+ JSONTypeVerifier verifier;
+ heap->IterateObjects(&verifier);
+}
+
} // namespace dart
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698