public Evaluate ( Context context, bool withvars = false ) : object | ||
context | Context | |
withvars | bool | |
Результат | object |
public void EvaluateUndefinedVariableExpression() { Variable variable = new Variable("X"); Context context = new Context(); VariableExpression expression = new VariableExpression(variable); Assert.AreEqual(variable, expression.Evaluate(context, true)); }
public void EvaluateVariableExpression() { Variable variable = new Variable("X"); Context context = new Context(); context.SetValue("X", 1); VariableExpression expression = new VariableExpression(variable); Assert.AreEqual(1, expression.Evaluate(context)); }
public void RaiseIfEvaluateUndefinedVariableExpression() { Variable variable = new Variable("X"); Context context = new Context(); VariableExpression expression = new VariableExpression(variable); try { expression.Evaluate(context, false); Assert.Fail(); } catch (Exception ex) { Assert.AreEqual("variable 'X' is unbound", ex.Message); } }