Beispiel #1
0
        public void Process_Should_Push_Literal_Value_Into_Stack()
        {
            var runnable = GetRunnableWithMainFor(GetInstructions());

            var context = new RuntimeContext(runnable);

            context.Execute();

            Assert.AreEqual(1, context.GetSymbolValue("main_x_0"));
        }
Beispiel #2
0
        public void Process_Should_Arithmetic_DIV()
        {
            var runnable = GetRunnableWithMainFor(GetInstructions());

            var context = new RuntimeContext(runnable);

            context.Execute();

            Assert.AreEqual(1, context.GetSymbolValue("main_x_0"));
            Assert.AreEqual(5, context.GetSymbolValue("main_y_0"));
            Assert.AreEqual(3.33333325f, context.GetSymbolValue("main_z_0"));
        }
Beispiel #3
0
        public void Process_Should_Arithmetic_NEG()
        {
            var runnable = GetRunnableWithMainFor(GetInstructions());

            var context = new RuntimeContext(runnable);

            context.Execute();

            Assert.AreEqual(-4, context.GetSymbolValue("main_x_0"));
            Assert.AreEqual(-8, context.GetSymbolValue("main_y_0"));
            Assert.AreEqual(-9, context.GetSymbolValue("main_z_0"));
            Assert.AreEqual(-16, context.GetSymbolValue("main_t_0"));
        }
Beispiel #4
0
        public void Process_Should_Declare_Local_Variables()
        {
            var runnable = GetRunnableWithMainFor(GetInstructions());

            var context = new RuntimeContext(runnable);

            context.Execute();

            var valuex = context.GetSymbolValue("main_x_0");
            var valuey = context.GetSymbolValue("main_y_0");
            var valuez = context.GetSymbolValue("main_z_0");
            var valuet = context.GetSymbolValue("main_t_0");

            Assert.AreEqual(null, valuex);
            Assert.AreEqual(null, valuey);
            Assert.AreEqual(null, valuez);
            Assert.AreEqual(null, valuet);
        }
Beispiel #5
0
        public void FactorialCalc()
        {
            var runnable = GetRunnableFor("fat", GetInstructions());

            var context = new RuntimeContext(runnable);

            var total = context.Execute("fat", 3);

            Assert.AreEqual(6, total);
            Assert.AreEqual(1, context.Execute("fat", 0));
            Assert.AreEqual(1, context.Execute("fat", 1));
            Assert.AreEqual(24, context.Execute("fat", 4));
            Assert.AreEqual(120, context.Execute("fat", 5));
            Assert.AreEqual(720, context.Execute("fat", 6));
        }
Beispiel #6
0
        public void Process_Should_Assign_Indexed_Variable_With_Indexed_Variable()
        {
            var runnable = GetRunnableWithMainFor(GetInstructions4());

            var script = runnable;

            var context = new RuntimeContext(script);

            context.Execute();

            var value = context.GetSymbolValue("main_list_0", 1);

            Assert.AreEqual("teste", value);
        }
Beispiel #7
0
        public void Process_Should_Assign_Local_Variable_With_Other_Variable()
        {
            var runnable = GetRunnableWithMainFor(GetInstructions2());

            var script = runnable;

            var context = new RuntimeContext(script);

            context.Execute();

            var value = context.GetSymbolValue("main_name2_0");

            Assert.AreEqual("Ricardo", value);
        }
        public void Process_Should_Invoke_Defined_Function_With_Params()
        {
            var runnable = BuildWithParamsScript();

            var context = new RuntimeContext(runnable);

            context.Execute();

            Assert.AreEqual("Mundo", context.GetSymbolValue("do_y_1"));
            Assert.AreEqual("Mundo", context.GetSymbolValue("main_x_0"));
            Assert.AreEqual("temp", context.GetSymbolValue("do_x_1"));
            Assert.AreEqual("Ola", context.GetSymbolValue("main_msg_0"));
        }