public void TestMultiDimensionaldArray() { var heap = new Heap(); var array1 = heap.AllocateArray(new StackValue[] { StackValue.BuildInt(0) }); var array2 = heap.AllocateArray(new StackValue[] { array1 }); var array3 = heap.AllocateArray(new StackValue[] { array2 }); heap.FullGC(new List<StackValue>() {}, testExecutive); Assert.IsNull(heap.ToHeapObject<DSArray>(array1)); Assert.IsNull(heap.ToHeapObject<DSArray>(array2)); Assert.IsNull(heap.ToHeapObject<DSArray>(array3)); }
public void TestBasic() { var heap = new Heap(); var values = new StackValue[] { StackValue.BuildInt(0), StackValue.BuildInt(1), StackValue.BuildInt(2) }; var array = heap.AllocateArray(values); var str = heap.AllocateString("hello world"); heap.FullGC(new List<StackValue>(), testExecutive); Assert.IsNull(heap.ToHeapObject<DSArray>(array)); Assert.IsNull(heap.ToHeapObject<DSArray>(str)); }
public void TestDictionary() { var heap = new Heap(); var key = heap.AllocateArray(new StackValue[] { StackValue.BuildInt(42) }); var val = heap.AllocateString("Hello world"); var dict = new Dictionary<StackValue, StackValue>(); dict[key] = val; var array = heap.AllocateArray(new StackValue[] { }); heap.FullGC(new List<StackValue>() {}, testExecutive); Assert.IsNull(heap.ToHeapObject<DSArray>(val)); Assert.IsNull(heap.ToHeapObject<DSArray>(array)); }
public void TestCircularReference() { var heap = new Heap(); var svArray1 = heap.AllocateArray(new StackValue[] { StackValue.Null }); var svArray2 = heap.AllocateArray(new StackValue[] { svArray1 }); var array1 = heap.ToHeapObject<DSArray>(svArray1); // self reference array1.SetValueForIndex(0, svArray2, null); heap.FullGC(new List<StackValue>() { }, testExecutive); Assert.IsNull(heap.ToHeapObject<DSArray>(svArray1)); Assert.IsNull(heap.ToHeapObject<DSArray>(svArray2)); }