public void TestSpecializedBools()
        {
            ExpressionParser e         = new ExpressionParser();
            VariableSet      variables = new VariableSet(null, new TestVariableFactory());

            variables.RegisterVariable(OperandType.NullableBool, "Left", true);
            variables.RegisterVariable(OperandType.Bool, "Right", true);

            variables.SetVariableValue("Right", false);
            variables.SetVariableValue("Right", true);
            variables.SetVariableValue("Right", false);

            bool?left  = true;
            bool right = false;

            bool expectedResult = left == right;

            var compiledExpression = e.Parse("Left == Right");

            var evalResult = compiledExpression.Evaluate(variables);

            Assert.AreEqual(1, evalResult.Count);
            bool actualResult = (bool)evalResult.Pop().GetValue();

            Assert.AreEqual(expectedResult, actualResult);
            Assert.AreEqual(3, ((CrazyBool)variables.GetVariable("Right")).ChangeCount);
        }
Beispiel #2
0
        public void TestSimpleDottedAssignment()
        {
            VariableSet daddyVarbs = new VariableSet();
            VariableSet childVarbs = new VariableSet();

            daddyVarbs.RegisterVariable(OperandType.Long, "daddyLong", 5);
            childVarbs.RegisterVariable(OperandType.Long, "childLong", 6);
            childVarbs.RegisterVariable(OperandType.VSet, "daddy", daddyVarbs);

            childVarbs.SetVariableValue("daddy.daddyLong", (long)42);
            var actualResult  = (long)childVarbs.GetVariable("daddy.daddyLong").Value;
            var actualResult2 = (long)daddyVarbs.GetVariable("daddyLong").Value;

            long expectedResult = 42;

            Assert.AreEqual(expectedResult, actualResult);
            Assert.AreEqual(expectedResult, actualResult2);
        }