Skip to content

Commit

Permalink
Added test for free
Browse files Browse the repository at this point in the history
  • Loading branch information
quajak committed Dec 24, 2021
1 parent c2fb436 commit 5e960a7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Tests/Kernels/Cosmos.Compiler.Tests.TypeSystem/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Cosmos.Core;
using Cosmos.Debug.Kernel;
using Cosmos.IL2CPU;
using Cosmos.Core.Memory;

namespace Cosmos.Compiler.Tests.TypeSystem
{
Expand Down Expand Up @@ -69,9 +70,13 @@ private void TestVTablesImpl()

private void TestGarbageCollector()
{
int allocated = HeapSmall.GetAllocatedObjectCount();
object a = new object();

int nowAllocated = HeapSmall.GetAllocatedObjectCount();
GCImplementation.Free(a);
int afterFree = HeapSmall.GetAllocatedObjectCount();
Assert.AreEqual(allocated + 1, nowAllocated, "NewObj causes one object to be allocated");
Assert.AreEqual(allocated, afterFree, "Free causes one object to be freed again");
}

protected override void Run()
Expand Down

0 comments on commit 5e960a7

Please sign in to comment.