Пример #1
0
        public void SubstitutionSimpleTest()
        {
            BaseExpression exprExpected = BaseExpression.Parse("3 + (-1 * -4) / 2 - 0 % 17");

            BaseExpression expr  = BaseExpression.Parse("x + (y * z) / w - k % l");
            var            subst = new Dictionary <string, BaseExpression>();

            subst["x"] = new IntegerExpression(3);
            subst["y"] = new IntegerExpression(-1);
            subst["z"] = new IntegerExpression(-4);
            subst["w"] = new IntegerExpression(2);
            subst["k"] = new IntegerExpression(0);
            subst["l"] = new IntegerExpression(17);
            BaseExpression exprSubst = expr.Subst(subst);

            exprExpected.EvaluateBe().ExtractRawInteger(out var expected);
            exprSubst.EvaluateBe().ExtractRawInteger(out var actual);
            Assert.AreEqual(expected, actual);
        }