AK.ExpressionSolverTests.TestExpLocalConstants C# (CSharp) Method

TestExpLocalConstants() public static method

public static TestExpLocalConstants ( ) : void
return void
        public static void TestExpLocalConstants()
        {
            ExpressionSolver solver = new ExpressionSolver();
            var exp1 = solver.SymbolicateExpression("test+1",new string[]{"test"});
            exp1.SetVariable("test",1.0);
            var exp2 = solver.SymbolicateExpression("test+1","test"); // If you define only one variable, you don't need to use the string[] format
            exp2.SetVariable("test",2.0);
            solver.SetGlobalVariable("test",1000); // If there is name clash with a exp-local variable, we prefer the exp-local variable.
            AssertSameValue(exp1.Evaluate(),2);
            AssertSameValue(exp2.Evaluate(),3);
            var exp3 = solver.SymbolicateExpression("test^2");
            AssertSameValue(exp3.Evaluate(),1000*1000);
        }