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

Unified Diff: runtime/vm/object_graph_test.cc

Issue 286203015: ObjectGraph::RetainingPath (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | « runtime/vm/object_graph.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_graph_test.cc
===================================================================
--- runtime/vm/object_graph_test.cc (revision 36049)
+++ runtime/vm/object_graph_test.cc (working copy)
@@ -91,6 +91,38 @@
EXPECT_EQ(a_size + b_size + c_size + d_size,
graph.SizeRetainedByInstance(a));
}
+ {
+ // Get hold of c again.
+ b ^= a.At(0);
+ c ^= b.At(0);
+ b = Array::null();
+ ObjectGraph graph(isolate);
+ // A retaining path should end like this: c <- b <- a <- ...
+ // c itself is not included in the returned path and length.
+ {
+ HANDLESCOPE(isolate);
+ // Test null, empty, and length 1 array.
+ intptr_t null_length = graph.RetainingPath(&c, Object::null_array());
+ intptr_t empty_length = graph.RetainingPath(&c, Object::empty_array());
+ Array& path = Array::Handle(Array::New(1, Heap::kNew));
+ intptr_t one_length = graph.RetainingPath(&c, path);
+ EXPECT_EQ(null_length, empty_length);
+ EXPECT_EQ(null_length, one_length);
+ EXPECT_LE(2, null_length);
+ }
+ {
+ HANDLESCOPE(isolate);
+ Array& path = Array::Handle(Array::New(2, Heap::kNew));
+ intptr_t length = graph.RetainingPath(&c, path);
+ EXPECT_LE(2, length);
+ Array& expected_b = Array::Handle();
+ expected_b ^= path.At(0);
+ Array& expected_a = Array::Handle();
+ expected_a ^= path.At(1);
+ EXPECT(expected_b.raw() == a.At(0));
+ EXPECT(expected_a.raw() == a.raw());
+ }
+ }
}
} // namespace dart
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698