Beispiel #1
0
        public void Pop_an_empty_heap()
        {
            AMHeap heap = new AMHeap();

            object top = heap.Pop();

            Assert.IsNull(top);
        }
Beispiel #2
0
        public void SetVoid()
        {
            AbstractMachineState state = SetupMachine();
            AMHeap heap = (AMHeap)state.DataArea;


            object[] args = { "3" };

            SetVoidInstruction i = new SetVoidInstruction();

            i.Process(args);
            i.Execute(state);

            Assert.AreEqual("set_void", i.Name());
            Assert.AreEqual(1, i.NumberOfArguments());
            Assert.IsTrue(((AbstractTerm)heap.Pop()).IsReference);
            Assert.IsTrue(((AbstractTerm)heap.Pop()).IsReference);
            Assert.IsTrue(((AbstractTerm)heap.Pop()).IsReference);
        }
Beispiel #3
0
        public void Pop_one_item()
        {
            AMHeap heap = new AMHeap();

            ConstantTerm con = new ConstantTerm("ali");

            heap.Push(con);

            heap.Pop();

            Assert.IsNull(heap.Top());
        }
Beispiel #4
0
        public void Pop_two_items()
        {
            AMHeap heap = new AMHeap();

            ConstantTerm con   = new ConstantTerm("ali");
            ConstantTerm first = new ConstantTerm("foo");

            heap.Push(first);
            heap.Push(con);

            heap.Pop();

            Assert.AreSame(first, heap.Top());
        }