public override void Visit(Decr decr)
 {
     Visit(new Ass(decr.Id, new AddOp {
         Add = Add.Minus, Lhs = new ID {
             Id = decr.Id
         }, Rhs = new Int {
             Value = 1
         }
     }));
 }
Example #2
0
        public void SML_Instruction_Decr_Bad_Stack()
        {
            Mock <IVirtualMachine> mock = new Mock <IVirtualMachine>(MockBehavior.Strict);
            Decr decr = new Decr
            {
                VirtualMachine = mock.Object
            };

            mock.Setup(m => m.Stack).Returns(new Stack());

            decr.Run();
        }
Example #3
0
        public void SML_Instruction_Decr_Bad_Item()
        {
            string inputOne = "2";

            Stack stack = new Stack();
            Mock <IVirtualMachine> mock = new Mock <IVirtualMachine>(MockBehavior.Strict);
            Decr decr = new Decr
            {
                VirtualMachine = mock.Object
            };

            mock.Setup(m => m.Stack).Returns(stack);

            stack.Push(inputOne);

            decr.Run();
        }
Example #4
0
        public void SML_Instruction_Decr_Good()
        {
            int inputOne = 2;
            int expected = inputOne - 1;

            Stack stack = new Stack();
            Mock <IVirtualMachine> mock = new Mock <IVirtualMachine>(MockBehavior.Strict);
            Decr decr = new Decr
            {
                VirtualMachine = mock.Object
            };

            mock.Setup(m => m.Stack).Returns(stack);

            stack.Push(inputOne);

            decr.Run();

            Assert.AreEqual(mock.Object.Stack.Pop(), expected);
        }
Example #5
0
 public virtual void Visit(Decr decr)
 {
 }