public void SetEndLocal() { EngineState s = EngineTests.CreateEngineState(); void SingleTemplate(List <string> rawCodes, string destComp, string retComp, ErrorCheck check = ErrorCheck.Success) { s.Variables.DeleteKey(VarsType.Local, "Dest"); s.ReturnValue = string.Empty; EngineTests.EvalLines(s, rawCodes, check); if (check == ErrorCheck.Success || check == ErrorCheck.Warning) { string dest = s.Variables["Dest"]; string ret = s.ReturnValue; Assert.IsTrue(dest.Equals(destComp, StringComparison.Ordinal)); Assert.IsTrue(ret.Equals(retComp, StringComparison.Ordinal)); } } void ScriptTemplate(string treePath, string entrySection, string destComp, string retComp, ErrorCheck check = ErrorCheck.Success) { s.Variables.DeleteKey(VarsType.Local, "Dest"); s.ReturnValue = string.Empty; (EngineState st, _) = EngineTests.EvalScript(treePath, check, entrySection); if (check == ErrorCheck.Success || check == ErrorCheck.Warning) { string dest = st.Variables["Dest"]; string ret = st.ReturnValue; Assert.IsTrue(dest.Equals(destComp, StringComparison.Ordinal)); Assert.IsTrue(ret.Equals(retComp, StringComparison.Ordinal)); } } SingleTemplate(new List <string> { @"Set,%Dest%,0", @"Set,#r,A", @"System,SetLocal", @"Set,%Dest%,1", @"Set,#r,B", @"System,EndLocal", }, "0", "B"); SingleTemplate(new List <string> { @"System,SetLocal", @"System,SetLocal", @"System,EndLocal", }, null, null, ErrorCheck.RuntimeError); SingleTemplate(new List <string> { @"System,EndLocal", }, null, null, ErrorCheck.RuntimeError); string scPath = Path.Combine(EngineTests.Project.ProjectName, "System", "SetEndLocal.script"); ScriptTemplate(scPath, "Process-Simple", "0", "B"); ScriptTemplate(scPath, "Process-Branch", "0", "B"); ScriptTemplate(scPath, "Process-ImplicitEnd", "-1", "A", ErrorCheck.Warning); }
public void BranchCondition_Single_Template(EngineState s, string rawCode, string comp) { s.Variables["Dest"] = "F"; EngineTests.EvalLines(s, new List <string> { rawCode }, CodeType.If, ErrorCheck.Success); Assert.IsTrue(s.Variables["Dest"].Equals(comp, StringComparison.Ordinal)); }
public void ErrorOff() { EngineState s = EngineTests.CreateEngineState(); void SingleTemplate(List <string> rawCodes, ErrorCheck check = ErrorCheck.Success) { EngineTests.EvalLines(s, rawCodes, check); } void ScriptTemplate(string treePath, ErrorCheck check = ErrorCheck.Success) { EngineTests.EvalScript(treePath, check); } SingleTemplate(new List <string> { @"System,ErrorOff", @"Error1", }); SingleTemplate(new List <string> { @"System,ErrorOff,3", @"Error1", @"Error2", @"Error3", }); SingleTemplate(new List <string> { @"System,ErrorOff,2", @"Error1", @"Error2", @"Error3", }, ErrorCheck.RuntimeError); string scPath = Path.Combine(EngineTests.Project.ProjectName, "System", "ErrorOff.script"); ScriptTemplate(scPath); }