Ejemplo n.º 1
0
        public RuntimeContext(Runnable runnable, IHospedagem hospedagem)
        {
            Runnable = runnable;

            Hospedagem = hospedagem;

            executor = new Executor(this);
        }
Ejemplo n.º 2
0
        public RuntimeContext(Runnable runnable)
        {
            Runnable = runnable;

            Hospedagem = new Hospedagem();

            executor = new Executor(this);
        }
Ejemplo n.º 3
0
        public void Process_Should_Declare_Variable()
        {
            var contextMock = new Mock<IRuntimeContext>();

            contextMock.Setup(x => x.CurrentInst).Returns(
                new Instruction(OpCode.JMP, 0, new Operand(OperandType.Literal, 5))
                );

            contextMock.Setup(x => x.CurrentFunction).Returns(GetMainFunction());

            contextMock.Setup(x => x.Runnable).Returns(GetRunnable());

            var executor = new Executor(contextMock.Object);

            executor.ExecuteInstruction();

            Assert.AreEqual(5, contextMock.Object.Runnable.IP);
        }
Ejemplo n.º 4
0
        public void Process_Should_Declare_Variable()
        {
            var contextMock = new Mock<IRuntimeContext>();

            contextMock.Setup(x => x.CurrentInst).Returns(
                new Instruction(OpCode.DCL, 0, new Operand(OperandType.Variable, "x"))
                );

            contextMock.Setup(x => x.CurrentFunction).Returns(GetMainFunction());

            contextMock.Setup(x => x.Runnable).Returns(GetRunnable());

            var executor = new Executor(contextMock.Object);

            executor.ExecuteInstruction();

            Assert.IsTrue(executor.SymbolTable.ContainsKey(SymbolId("x")));
        }