public void ExpandVariables_6()
        {
            EngineState s = EngineTests.CreateEngineState();

            s.CurDepth = 2;

            // In real world, a value must be set with SetValue, so circular reference of variables does not happen
            s.Variables.SetValue(VarsType.Local, "A", "%B%");
            s.Variables.SetValue(VarsType.Local, "B", "%C%");
            s.Variables.SetValue(VarsType.Local, "C", "%A%"); // Set to [#$pC#4p], preventing circular reference
            s.CurSectionParams[1] = "#2";

            string src = "%A% #1";
            string dest;

            try { dest = StringEscaper.ExpandVariables(s, src); }
            catch (VariableCircularReferenceException) { return; }

            Assert.Fail();
        }
Exemple #2
0
        public static EngineState EvalLines(EngineState s, List<string> rawCodes, CodeType type, ErrorCheck check, out List<CodeCommand> cmds)
        {
            // Create CodeCommand
            SectionAddress addr = EngineTests.DummySectionAddress();
            cmds = CodeParser.ParseStatements(rawCodes, addr, out List<LogInfo> errorLogs);
            if (0 < errorLogs.Where(x => x.State == LogState.Error).Count())
            { 
                Assert.IsTrue(check == ErrorCheck.ParserError);
                return s;
            }
            Assert.IsTrue(cmds[0].Type == type);

            // Run CodeCommand
            List<LogInfo> logs = Engine.ExecuteCommand(s, cmds[0]);

            // Assert
            EngineTests.CheckErrorLogs(logs, check);

            // Return EngineState
            return s;
        }
        public void Preprocess_6()
        {
            EngineState s = EngineTests.CreateEngineState();

            s.CurDepth = 2;

            // In real world, a value must be set with SetVariables, so circular reference of variables does not happen
            s.Variables.SetValue(VarsType.Local, "A", "%B%");
            s.Variables.SetValue(VarsType.Local, "B", "%C%");
            s.Variables.SetValue(VarsType.Local, "C", "%A%");
            Variables.SetVariable(s, "#1", "#2");
            Variables.SetVariable(s, "#2", "#3");
            Variables.SetVariable(s, "#3", "#1");

            string src = "%A% #1";

            try { string dest = StringEscaper.Preprocess(s, src); }
            catch (VariableCircularReferenceException) { return; }

            Assert.Fail();
        }
Exemple #4
0
        public static EngineState Eval(EngineState s, string rawCode, CodeType type, ErrorCheck check, out CodeCommand cmd)
        {
            // Create CodeCommand
            SectionAddress addr = EngineTests.DummySectionAddress();
            cmd = CodeParser.ParseStatement(rawCode, addr);
            if (cmd.Type == CodeType.Error)
            {
                Console.WriteLine((cmd.Info as CodeInfo_Error).ErrorMessage);
                Assert.IsTrue(check == ErrorCheck.ParserError);
                return s;
            }
            Assert.IsTrue(cmd.Type == type);

            // Run CodeCommand
            List<LogInfo> logs = Engine.ExecuteCommand(s, cmd);

            // Assert
            EngineTests.CheckErrorLogs(logs, check);

            // Return EngineState
            return s;
        }
Exemple #5
0
        public static EngineState Eval(string rawCode, CodeType type, ErrorCheck check, out CodeCommand cmd)
        {
            EngineState s = EngineTests.CreateEngineState();

            return(EngineTests.Eval(s, rawCode, type, check, out cmd));
        }
Exemple #6
0
 public static EngineState Eval(string rawCode, CodeType type, ErrorCheck check)
 {
     EngineState s = EngineTests.CreateEngineState();
     return EngineTests.Eval(s, rawCode, type, check);
 }