Chromium Code Reviews| Index: runtime/bin/vmservice/observatory/test/graph_test.dart |
| =================================================================== |
| --- runtime/bin/vmservice/observatory/test/graph_test.dart (revision 42076) |
| +++ runtime/bin/vmservice/observatory/test/graph_test.dart (working copy) |
| @@ -12,16 +12,22 @@ |
| Object left; |
| Object right; |
| } |
| -Foo root; |
| +Foo r; |
| +List lst; |
| + |
| void script() { |
| - // Create 3 instances of Foo, with out-degrees 0 (for b), 1 (for a), and 2 (for root). |
| - root = new Foo(); |
| + // Create 3 instances of Foo, with out-degrees 0 (for b), 1 (for a), and 2 (for staticFoo). |
|
Cutch
2014/12/04 18:34:54
Over 80 column limit here and elsewhere
koda
2014/12/04 19:27:27
Done.
|
| + r = new Foo(); |
| var a = new Foo(); |
| var b = new Foo(); |
| - root.left = a; |
| - root.right = b; |
| + r.left = a; |
| + r.right = b; |
| a.left = b; |
| + |
| + lst = new List(2); |
| + lst[0] = lst; // Self-loop. |
| + lst[1] = new List(123456); // Larger than any other fixed-size list in a fresh heap. |
|
Cutch
2014/12/04 18:34:54
Over 80 column limit here and elsewhere
koda
2014/12/04 19:27:27
Done.
|
| } |
| int fooId; |
| @@ -40,6 +46,31 @@ |
| expect(foos.where((ObjectVertex obj) => obj.succ.length == 0).length, equals(1)); |
| expect(foos.where((ObjectVertex obj) => obj.succ.length == 1).length, equals(1)); |
| expect(foos.where((ObjectVertex obj) => obj.succ.length == 2).length, equals(1)); |
| + |
| + ObjectVertex bVertex = foos.where((ObjectVertex obj) => obj.succ.length == 0).first; |
| + ObjectVertex aVertex = foos.where((ObjectVertex obj) => obj.succ.length == 1).first; |
| + ObjectVertex rVertex = foos.where((ObjectVertex obj) => obj.succ.length == 2).first; |
| + |
| + // TODO(koda): Check actual byte sizes after implementing "architecture" in VM. |
| + |
| + expect(aVertex.retainedSize, equals(aVertex.shallowSize)); |
| + expect(bVertex.retainedSize, equals(bVertex.shallowSize)); |
| + expect(rVertex.retainedSize, equals(aVertex.shallowSize + |
| + bVertex.shallowSize + |
| + rVertex.shallowSize)); |
| + |
| + const int fixedSizeListCid = 62; |
| + List<ObjectVertex> lists = new List.from( |
| + graph.vertices.where((ObjectVertex obj) => obj.classId == fixedSizeListCid)); |
| + expect(lists.length >= 2, isTrue); |
| + // Order by decreasing retained size. |
| + lists.sort((u, v) => v.retainedSize - u.retainedSize); |
| + ObjectVertex first = lists[0]; |
| + ObjectVertex second = lists[1]; |
| + // Check that the short list 'lst' retains more than the long list inside it. |
| + expect(first.succ.length, equals(2 + second.succ.length)); |
| + // ... and specifically, that it retains exactly itself + the long one. |
| + expect(first.retainedSize, equals(first.shallowSize + second.shallowSize)); |
| completer.complete(); |
| } |
| }); |