Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/object_graph.h" | 6 #include "vm/object_graph.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 graph.IterateObjects(&with); | 84 graph.IterateObjects(&with); |
| 85 Counter without(b_raw, a.raw()); | 85 Counter without(b_raw, a.raw()); |
| 86 graph.IterateObjects(&without); | 86 graph.IterateObjects(&without); |
| 87 EXPECT_EQ(2, with.count() - without.count()); | 87 EXPECT_EQ(2, with.count() - without.count()); |
| 88 EXPECT_EQ(b_size + c_size, | 88 EXPECT_EQ(b_size + c_size, |
| 89 with.size() - without.size()); | 89 with.size() - without.size()); |
| 90 } | 90 } |
| 91 EXPECT_EQ(a_size + b_size + c_size + d_size, | 91 EXPECT_EQ(a_size + b_size + c_size + d_size, |
| 92 graph.SizeRetainedByInstance(a)); | 92 graph.SizeRetainedByInstance(a)); |
| 93 } | 93 } |
| 94 { | |
| 95 // Get hold of c again. | |
| 96 b ^= a.At(0); | |
| 97 c ^= b.At(0); | |
| 98 b = Array::null(); | |
| 99 Array& path = Array::Handle(Array::New(2, Heap::kNew)); | |
| 100 ObjectGraph graph(isolate); | |
| 101 // A retaining path should end like this: c <- b <- a <- ... | |
| 102 // c itself is not included in the returned path and length. | |
| 103 intptr_t length = graph.RetainingPath(&c, path); | |
| 104 EXPECT_LE(2, length); | |
| 105 Array& expected_b = Array::Handle(); | |
| 106 expected_b ^= path.At(0); | |
| 107 Array& expected_a = Array::Handle(); | |
| 108 expected_a ^= path.At(1); | |
| 109 EXPECT(expected_b.raw() == a.At(0)); | |
| 110 EXPECT(expected_a.raw() == a.raw()); | |
| 111 } | |
|
Cutch
2014/05/20 17:39:12
What about a test that doesn't have a path?
Also,
koda
2014/05/20 20:37:49
Done.
| |
| 94 } | 112 } |
| 95 | 113 |
| 96 } // namespace dart | 114 } // namespace dart |
| OLD | NEW |