Esempio n. 1
0
        public void Library_FunctionTypeOf()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("object", "object", ModuleTypeEnum.COMMON, false, _path + "Functions\\typeof_object.scr"),
                new ScriptModule("global", "global", ModuleTypeEnum.STARTUP, true, _path + "Functions\\typeof.scr")
            };

            ScriptCompiler    compiler    = new ScriptCompiler();
            ScriptProgramm    programm    = compiler.CompileProgramm(modules);
            ScriptInterpreter interpreter = new ScriptInterpreter(programm);

            foreach (InternalScriptType type in interpreter.Programm.InternalTypes)
            {
                Console.WriteLine(type.Description);
            }
            Console.WriteLine("--");

            interpreter.Debugger.AddBreakpoint("global", 68, (interpreater) =>
            {
                Assert.AreEqual(68, interpreter.CurrentLine);
                //Assert.AreEqual(interpreter.Programm.InternalTypes.Count, interpreter.Debugger.Eval("счетчик").AsInt());
            });

            interpreter.Debug();
        }
Esempio n. 2
0
        public void Compile_ForError4()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("for", "for", ModuleTypeEnum.STARTUP, false, _path + "For\\for_error4.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 3
0
        public void Compile_Procedure_RepeatError()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("procedure", "procedure", ModuleTypeEnum.STARTUP, true, _path + "Procedure\\procedure_var_repeat_error.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 4
0
        public void Compile_Var_OrderError2()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("var", "var", ModuleTypeEnum.STARTUP, true, _path + "Var\\var_order_error2.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 5
0
        public void Compile_RaiseWoError()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("raise", "raise", ModuleTypeEnum.STARTUP, false, _path + "Exception\\raise_wo_error.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 6
0
        public void Compile_LoopWordsError2()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("while", "while", ModuleTypeEnum.STARTUP, false, _path + "While\\loop_words_error2.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 7
0
        public void Compile_Try()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("try", "try", ModuleTypeEnum.STARTUP, false, _path + "Exception\\try.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 8
0
        public void Compile_Procedure_CallNotFoundError()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("procedure", "procedure", ModuleTypeEnum.STARTUP, true, _path + "Procedure\\procedure_call_not_found.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 9
0
        public void Compile_Procedure_AsFunctionError5()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("procedure", "procedure", ModuleTypeEnum.STARTUP, true, _path + "Procedure\\procedure_as_function_error5.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 10
0
        public void Compile_GotoError7()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("goto", "goto", ModuleTypeEnum.STARTUP, false, _path + "Goto\\goto_error7.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 11
0
        public void Compile_EvalError()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("eval", "eval", ModuleTypeEnum.STARTUP, false, _path + "Eval\\eval_error.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 12
0
        public void Compile_NewType2Erorr()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("new", "new", ModuleTypeEnum.STARTUP, false, _path + "New\\type2_error.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 13
0
        public void Compile_ExtensionFunctionCall()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("function", "function", ModuleTypeEnum.STARTUP, false, _path + "Extension\\function call.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 14
0
        public void Compile_ArrayIndexer()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("global", "global", ModuleTypeEnum.STARTUP, false, _path + "Array\\indexer.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 15
0
        public void Compile_Other_ThrowError()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("other", "other", ModuleTypeEnum.STARTUP, true, _path + "Other\\throw_error.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 16
0
        public void Compile_Var_AllTypes()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("var", "var", ModuleTypeEnum.STARTUP, true, _path + "Var\\var_all_types.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 17
0
        public void Compile_IfError3()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("if", "if", ModuleTypeEnum.STARTUP, false, _path + "If\\if_error3.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 18
0
        public void Compile_Procedure_ParamCountError2()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("procedure", "procedure", ModuleTypeEnum.STARTUP, true, _path + "Procedure\\procedure_error_param_count2.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 19
0
        public void Compile_Function_EmptyReturn()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("function", "function", ModuleTypeEnum.STARTUP, true, _path + "Function\\function_empty_return.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 20
0
        public void Compile_WhileWoSemicolon()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("while", "while", ModuleTypeEnum.STARTUP, false, _path + "While\\while_wo_semicolon.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 21
0
        public void Compile_Function_AssignResult()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("function", "function", ModuleTypeEnum.STARTUP, true, _path + "Function\\assign_result.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 22
0
        public void Сompile_Objects_CrossObjectCall()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("global", "global", ModuleTypeEnum.STARTUP, true, _path + "Objects\\Cross object call\\global_module.scr"),
                new ScriptModule("object", "object", ModuleTypeEnum.OBJECT, true, _path + "Objects\\Cross object call\\object_module.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 23
0
        public void Compile_Global_CommonWithCodeError()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("global", "global", ModuleTypeEnum.STARTUP, true, _path + "Global\\Common with code error\\global_module.scr"),
                new ScriptModule("object", "object", ModuleTypeEnum.COMMON, true, _path + "Global\\Common with code error\\object_module.scr")
            };

            ScriptCompiler compiler = new ScriptCompiler();

            compiler.CompileProgramm(modules);
        }
Esempio n. 24
0
        public void Library_MapCollection()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("global", "global", ModuleTypeEnum.STARTUP, true, _path + "map.scr")
            };

            ScriptCompiler    compiler    = new ScriptCompiler();
            ScriptProgramm    programm    = compiler.CompileProgramm(modules);
            ScriptInterpreter interpreter = new ScriptInterpreter(programm);

            interpreter.Debugger.AddBreakpoint("global", 7, (interpreater) =>
            {
                Assert.AreEqual(7, interpreter.CurrentLine);
                Assert.AreEqual("Олимпиада в Москве", interpreter.Debugger.RegisterGetValue("значение").AsString());
                Assert.AreEqual("Первый полет человека в космос.", interpreter.Debugger.RegisterGetValue("значение2").AsString());
            });


            interpreter.Debugger.AddBreakpoint("global", 10, (interpreater) =>
            {
                Assert.AreEqual(10, interpreter.CurrentLine);
            });


            interpreter.Debugger.AddBreakpoint("global", 14, (interpreater) =>
            {
                Assert.AreEqual(14, interpreter.CurrentLine);
                Assert.AreEqual("Олимпиада в Москве", interpreter.Debugger.RegisterGetValue("значение").AsString());
                Assert.AreEqual("Первый полет человека в космос.", interpreter.Debugger.RegisterGetValue("значение2").AsString());
            });

            interpreter.Debugger.AddBreakpoint("global", 17, (interpreater) =>
            {
                Assert.AreEqual(17, interpreter.CurrentLine);
                Assert.AreEqual("Первый полет Гагарина в космос.", interpreter.Debugger.RegisterGetValue("значение2").AsString());
            });

            interpreter.Debugger.AddBreakpoint("global", 24, (interpreater) =>
            {
                Assert.AreEqual(24, interpreter.CurrentLine);
                Assert.AreEqual(2, interpreter.Debugger.RegisterGetValue("counter").AsInt());
            });

            interpreter.Debugger.AddBreakpoint("global", 26, (interpreater) =>
            {
                Assert.AreEqual(26, interpreter.CurrentLine);
                Assert.AreEqual(0, interpreter.Debugger.RegisterGetValue("значение").AsInt());
            });


            interpreter.Debug();
        }
Esempio n. 25
0
        public void Library_SystemInfo()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("global", "global", ModuleTypeEnum.STARTUP, true, _path + "systeminfo.scr")
            };

            ScriptCompiler    compiler    = new ScriptCompiler();
            ScriptProgramm    programm    = compiler.CompileProgramm(modules);
            ScriptInterpreter interpreter = new ScriptInterpreter(programm);

            interpreter.Debug();
        }
Esempio n. 26
0
        public void SpeedTest_Structure()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("struct", "struct", ModuleTypeEnum.STARTUP, false, _path + "structure.scr")
            };

            ScriptCompiler    compiler    = new ScriptCompiler();
            ScriptProgramm    programm    = compiler.CompileProgramm(modules);
            ScriptInterpreter interpreter = new ScriptInterpreter(programm);

            System.Diagnostics.Stopwatch sw = new Stopwatch();
            sw.Start();
            interpreter.Run();
            sw.Stop();

            Assert.AreEqual(2000, sw.ElapsedMilliseconds, 200);
        }
Esempio n. 27
0
        public void SpeedTest_Precalc_Debug()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("other", "other", ModuleTypeEnum.STARTUP, false, _path + "speed_test.scr")
            };

            ScriptCompiler    compiler    = new ScriptCompiler();
            ScriptProgramm    programm    = compiler.CompileProgramm(modules);
            ScriptInterpreter interpreter = new ScriptInterpreter(programm);

            interpreter.Debugger.AddBreakpoint("other", 107, (interpreter_int) =>
            {
                Assert.AreEqual(107, interpreter.CurrentLine, 10);
                Assert.AreEqual(1000000, interpreter.Debugger.RegisterGetValue("ф").AsInt());
            });
            interpreter.Debug();
        }
Esempio n. 28
0
        public void SpeedTest_FunctionCall()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("function", "function", ModuleTypeEnum.STARTUP, false, _path + "speed_test_function_call.scr")
            };

            ScriptCompiler    compiler    = new ScriptCompiler();
            ScriptProgramm    programm    = compiler.CompileProgramm(modules);
            ScriptInterpreter interpreter = new ScriptInterpreter(programm);

            System.Diagnostics.Stopwatch sw = new Stopwatch();
            sw.Start();
            interpreter.Run();
            sw.Stop();

            Assert.AreEqual(3400, sw.ElapsedMilliseconds, 350);
        }
Esempio n. 29
0
        public void SpeedTest_ArrayDebug()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("array_test", "foreach_test", ModuleTypeEnum.STARTUP, false, _path + "array.scr")
            };

            ScriptCompiler    compiler    = new ScriptCompiler();
            ScriptProgramm    programm    = compiler.CompileProgramm(modules);
            ScriptInterpreter interpreter = new ScriptInterpreter(programm);

            interpreter.Debugger.AddBreakpoint("array_test", 28, (interpreter_int) =>
            {
                Assert.AreEqual(499999500000, interpreter_int.Debugger.RegisterGetValue("result").AsNumber());
            });

            interpreter.Debug();
        }
Esempio n. 30
0
        public void OneScript_MainTest()
        {
            IList <ScriptModule> modules = new List <ScriptModule>()
            {
                new ScriptModule("global", "global", ModuleTypeEnum.STARTUP, true, _path + "main_module.scr"),
                new ScriptModule("testrunner", "testrunner", ModuleTypeEnum.OBJECT, true, _path + "testrunner.scr"),
                new ScriptModule("Утверждения", "Approval", ModuleTypeEnum.OBJECT, true, _path + "xunit.scr"),
                new ScriptModule("Ожидаем", "Expect", ModuleTypeEnum.OBJECT, true, _path + "bdd.scr")
            };

            ScriptCompiler    compiler    = new ScriptCompiler();
            ScriptProgramm    programm    = compiler.CompileProgramm(modules);
            ScriptInterpreter interpreter = new ScriptInterpreter(programm);

            interpreter.Debugger.AddBreakpoint("testrunner", 357, (interpreter1) =>
            {
                IValue val1 = interpreter1.Debugger.Eval("ПервоеЗначение");
                IValue val2 = interpreter1.Debugger.Eval("ВтороеЗначение");
            });

            interpreter.Debug();
        }