Пример #1
0
        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.GCMarkAndSweep(new List<StackValue>(), testExecutive);
            Assert.IsNull(heap.ToHeapObject<DSArray>(array));
            Assert.IsNull(heap.ToHeapObject<DSArray>(str));
        }
Пример #2
0
        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.GCMarkAndSweep(new List<StackValue>(), testExecutive);

            HeapElement arrayHeapElement;
            Assert.IsFalse(heap.TryGetHeapElement(array, out arrayHeapElement));

            HeapElement strHeapElement;
            Assert.IsFalse(heap.TryGetHeapElement(str, out strHeapElement));
        }
Пример #3
0
 public static StackValue BuildString(string str, Heap heap)
 {
     return(heap.AllocateString(str));
 }
Пример #4
0
 public static StackValue BuildString(string str, Heap heap)
 {
     return heap.AllocateString(str);
 }
Пример #5
0
        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[] { }, dict);

            heap.GCMarkAndSweep(new List<StackValue>() {}, testExecutive);

            HeapElement valHeapElement;
            Assert.IsFalse(heap.TryGetHeapElement(val, out valHeapElement));

            HeapElement arrayHeapElement;
            Assert.IsFalse(heap.TryGetHeapElement(array, out arrayHeapElement));
        }
Пример #6
0
        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.GCMarkAndSweep(new List<StackValue>() {}, testExecutive);

            Assert.IsNull(heap.ToHeapObject<DSArray>(val));
            Assert.IsNull(heap.ToHeapObject<DSArray>(array));
        }