Ejemplo n.º 1
0
        public void VisitListNewInstruction_CreatesNewListOnTopOfValueStack()
        {
            var testVmContext = new TestVmContext();
            var sut           = new RuntimeVisitor(testVmContext);

            sut.VisitList(new ListNewInstruction());

            Assert.Single(testVmContext.ValueStack);
            var topValue = testVmContext.ValueStack.Pop();

            Assert.IsType <List <object> >(topValue);
            var theList = (List <object>)topValue;

            Assert.Empty(theList);
        }
Ejemplo n.º 2
0
        public void VisitListAddInstruction_AddsObjectToListInValueStack()
        {
            var testVmContext = new TestVmContext();

            testVmContext.ValueStack.Push(new List <object>());
            testVmContext.ValueStack.Push(42);
            var sut = new RuntimeVisitor(testVmContext);

            sut.VisitList(new ListAddInstruction());

            Assert.Single(testVmContext.ValueStack);
            var topValue = testVmContext.ValueStack.Pop();

            Assert.IsType <List <object> >(topValue);
            var theList = (List <object>)topValue;

            Assert.Single(theList);
            Assert.Equal(42, theList[0]);
        }