Beispiel #1
0
        public void InvalidLogicalGrouping(string transition)
        {
            ProcessingUnitMock pu         = new ProcessingUnitMock();
            BooleanExpression  expression = Interpreter.AsBooleanExpression(transition, pu);

            Assert.IsFalse(expression.IsValid());
        }
Beispiel #2
0
        public void BooleanIO(string iBKey, string bTest, bool iBValid, string iAKey, string assignment, bool iAValid)
        {
            var inputBoolKeys = new List <StateEntry <bool> >()
            {
                { new StateEntry <bool>(iBKey, true, "", "") }
            };
            var outputBoolKeys = new List <StateEntry <bool> >()
            {
                { new StateEntry <bool>(iAKey, true, "", "") }
            };
            var inputRegisters             = new StateTable(inputBoolKeys, new List <StateEntry <int> >());
            var outputRegisters            = new StateTable(outputBoolKeys, new List <StateEntry <int> >());
            ProcessingUnitMock pu          = new ProcessingUnitMock(inputRegisters, outputRegisters);
            BooleanExpression  expressionA = Interpreter.AsBooleanExpression(bTest, pu);

            if (iBValid)
            {
                Assert.IsTrue(expressionA.IsValid());
                Assert.IsEqual(expressionA.Result(pu), true);
            }
            else
            {
                Assert.IsTrue(expressionA == null || !expressionA.IsValid());
            }
            var ae = Osls.St.Assignment.Interpreter.AsAssignmentExpression(assignment, pu);

            if (iAValid)
            {
                Assert.IsTrue(ae.IsValid());
            }
            else
            {
                Assert.IsTrue(ae == null || !ae.IsValid());
            }
        }
Beispiel #3
0
        public void RelationalOperation(string transition, bool result)
        {
            ProcessingUnitMock pu         = new ProcessingUnitMock();
            BooleanExpression  expression = Interpreter.AsBooleanExpression(transition, pu);

            Assert.IsTrue(expression.IsValid());
            Assert.IsEqual(expression.Result(pu), result);
        }
        public void NumericalConstant(string text, int result)
        {
            ProcessingUnitMock  pu         = new ProcessingUnitMock();
            NumericalExpression expression = Interpreter.AsNumericalExpression(text, pu);

            Assert.IsTrue(expression.IsValid());
            Assert.IsEqual(expression.Result(pu), result);
        }
        public void NumericalVariables()
        {
            ProcessingUnitMock pu = new ProcessingUnitMock();

            pu.IntLookup.Add("intVar", 5);
            NumericalExpression expressionA = Interpreter.AsNumericalExpression("intVar", pu);

            Assert.IsTrue(expressionA.IsValid());
            Assert.IsEqual(expressionA.Result(pu), 5);
            NumericalExpression expressionB = Interpreter.AsNumericalExpression("invalidVar", pu);

            Assert.IsFalse(expressionB.IsValid());
        }
        public void NumericalIO()
        {
            var intKeys = new List <StateEntry <int> >
            {
                { new StateEntry <int>("testInt", 1, "", "") }
            };
            var inputRegisters              = new StateTable(new List <StateEntry <bool> >(), intKeys);
            var outputRegisters             = new StateTable(new List <StateEntry <bool> >(), new List <StateEntry <int> >());
            ProcessingUnitMock  pu          = new ProcessingUnitMock(inputRegisters, outputRegisters);
            NumericalExpression expressionA = Interpreter.AsNumericalExpression("testInt", pu);

            Assert.IsTrue(expressionA.IsValid());
            Assert.IsEqual(expressionA.Result(pu), 1);
            NumericalExpression expressionB = Interpreter.AsNumericalExpression("invalidInt", pu);

            Assert.IsFalse(expressionB.IsValid());
        }