Commit 8b3e66d5 authored by Anton Bikineev's avatar Anton Bikineev Committed by Commit Bot

cppgc: Make member_unittests use idiomatic allocation

Bug: chromium:1056170
Change-Id: I98bbff8d2938c6b34fe2c358d504ba6211ec8b54
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2140931Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67054}
parent 3d098174
......@@ -113,24 +113,11 @@ TEST_F(TraceTraitTest, TraceGCedMixinThroughTraceDescriptor) {
EXPECT_EQ(1u, GCed::trace_callcount);
}
namespace {
template <typename T>
class MemberHolder final : public GarbageCollected<MemberHolder<T>> {
public:
void Trace(Visitor* visitor) { visitor->Trace(ref); }
Member<T> ref;
};
} // namespace
TEST_F(VisitorTest, DispatchTraceGCed) {
auto* gced = MakeGarbageCollected<GCed>(GetHeap());
auto* holder = MakeGarbageCollected<MemberHolder<GCed>>(GetHeap());
holder->ref = gced;
DispatchingVisitor visitor(gced, gced);
Member<GCed> ref = MakeGarbageCollected<GCed>(GetHeap());
DispatchingVisitor visitor(ref, ref);
EXPECT_EQ(0u, GCed::trace_callcount);
visitor.Trace(holder->ref);
visitor.Trace(ref);
EXPECT_EQ(1u, GCed::trace_callcount);
}
......@@ -139,11 +126,10 @@ TEST_F(VisitorTest, DispatchTraceGCedMixin) {
auto* gced_mixin = static_cast<GCedMixin*>(gced_mixin_app);
// Ensure that we indeed test dispatching an inner object.
EXPECT_NE(static_cast<void*>(gced_mixin_app), static_cast<void*>(gced_mixin));
auto* holder = MakeGarbageCollected<MemberHolder<GCedMixin>>(GetHeap());
holder->ref = gced_mixin;
Member<GCedMixin> ref = gced_mixin;
DispatchingVisitor visitor(gced_mixin, gced_mixin_app);
EXPECT_EQ(0u, GCed::trace_callcount);
visitor.Trace(holder->ref);
visitor.Trace(ref);
EXPECT_EQ(1u, GCed::trace_callcount);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment