chromium/v8/test/unittests/heap/cppgc/garbage-collected-unittest.cc

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "include/cppgc/garbage-collected.h"

#include "include/cppgc/allocation.h"
#include "include/cppgc/type-traits.h"
#include "src/base/platform/mutex.h"
#include "src/heap/cppgc/heap-object-header.h"
#include "src/heap/cppgc/heap.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cppgc {
namespace internal {

namespace {

class GCed : public GarbageCollected<GCed> {};
class NotGCed {};
class Mixin : public GarbageCollectedMixin {};
class GCedWithMixin : public GarbageCollected<GCedWithMixin>, public Mixin {};
class OtherMixin : public GarbageCollectedMixin {};
class MergedMixins : public Mixin, public OtherMixin {};
class GCWithMergedMixins : public GCed, public MergedMixins {};

class GarbageCollectedTestWithHeap
    : public testing::TestSupportingAllocationOnly {};

}  // namespace

TEST(GarbageCollectedTest, GarbageCollectedTrait) {}

TEST(GarbageCollectedTest, GarbageCollectedMixinTrait) {}

TEST(GarbageCollectedTest, GarbageCollectedOrMixinTrait) {}

TEST(GarbageCollectedTest, GarbageCollectedWithMixinTrait) {}

namespace {

class ForwardDeclaredType;

}  // namespace

TEST(GarbageCollectedTest, CompleteTypeTrait) {}

TEST_F(GarbageCollectedTestWithHeap, GetObjectStartReturnsCurrentAddress) {}

namespace {

class GCedWithPostConstructionCallback final : public GCed {};
size_t GCedWithPostConstructionCallback::cb_callcount;

class MixinWithPostConstructionCallback {};
size_t MixinWithPostConstructionCallback::cb_callcount;

class GCedWithMixinWithPostConstructionCallback final
    : public GCed,
      public MixinWithPostConstructionCallback {};

}  // namespace
}  // namespace internal

template <>
struct PostConstructionCallbackTrait<
    internal::GCedWithPostConstructionCallback> {};

PostConstructionCallbackTrait<T, std::void_t<typename T::MarkerForMixinWithPostConstructionCallback>>;

namespace internal {

TEST_F(GarbageCollectedTestWithHeap, PostConstructionCallback) {}

TEST_F(GarbageCollectedTestWithHeap, PostConstructionCallbackForMixin) {}

namespace {

int GetDummyValue() {}

class CheckObjectInConstructionBeforeInitializerList final
    : public GarbageCollected<CheckObjectInConstructionBeforeInitializerList> {};

class CheckMixinInConstructionBeforeInitializerList
    : public GarbageCollectedMixin {};

class UnmanagedMixinForcingVTable {};

class CheckGCedWithMixinInConstructionBeforeInitializerList
    : public GarbageCollected<
          CheckGCedWithMixinInConstructionBeforeInitializerList>,
      public UnmanagedMixinForcingVTable,
      public CheckMixinInConstructionBeforeInitializerList {};

}  // namespace

TEST_F(GarbageCollectedTestWithHeap, GarbageCollectedInConstructionDuringCtor) {}

TEST_F(GarbageCollectedTestWithHeap,
       GarbageCollectedMixinInConstructionDuringCtor) {}

namespace {

struct MixinA : GarbageCollectedMixin {};
struct MixinB : GarbageCollectedMixin {};
struct GCed1 : GarbageCollected<GCed>, MixinA, MixinB {};
struct GCed2 : MixinA, MixinB {};

static_assert;
}  // namespace

}  // namespace internal
}  // namespace cppgc