예제 #1
0
        public void InvalidTooLargeJump()
        {
            var compiler = new BytecodeCompiler();

            compiler.Push(10000);
            compiler.Jump();
            compiler.Push(2);
            compiler.Push(3);
            compiler.Push(4);

            Machine machine = new Machine();

            machine.Execute(compiler.ToBytes());

            var stack = machine.Stack;

            Assert.AreEqual(0, stack.Size);
        }
예제 #2
0
        public void JumpPushes()
        {
            var compiler = new BytecodeCompiler();

            compiler.Push(9);
            compiler.Jump();
            compiler.Push(2);
            compiler.Push(3);
            compiler.Push(4);
            compiler.JumpDest();

            Machine machine = new Machine();

            machine.Execute(compiler.ToBytes());

            var stack = machine.Stack;

            Assert.AreEqual(0, stack.Size);
        }
예제 #3
0
        public void InvalidTooLargeJump()
        {
            var compiler = new BytecodeCompiler();

            compiler.Push(10000);
            compiler.Jump();
            compiler.Push(2);
            compiler.Push(3);
            compiler.Push(4);

            Machine machine = new Machine();

            try
            {
                machine.Execute(compiler.ToBytes());
            }
            catch (InvalidOperationException ex)
            {
                Assert.AreEqual("Invalid jump destination", ex.Message);
            }
        }
예제 #4
0
        public void JumpWithoutJumpDest()
        {
            var compiler = new BytecodeCompiler();

            compiler.Push(9);
            compiler.Jump();
            compiler.Push(2);
            compiler.Push(3);
            compiler.Push(4);
            compiler.Push(5);

            Machine machine = new Machine();

            try
            {
                machine.Execute(compiler.ToBytes());
                Assert.Fail();
            }
            catch (InvalidOperationException ex)
            {
                Assert.AreEqual("Invalid jump destination", ex.Message);
            }
        }