public Evaluate ( Context context, bool withvars = false ) : object | ||
context | Context | |
withvars | bool | |
return | object |
public object Evaluate(Context context, bool withvars = false)
{
IList<object> elements = new List<object>();
foreach (var expr in this.expressions)
elements.Add(expr.Evaluate(context, withvars));
return new Tuple(elements);
}
public void RaiseIfTupleHasVariable() { Context context = new Context(); var expr = new TupleExpression(new IExpression[] { new ConstantExpression(1), new VariableExpression(new Variable("X")), new AtomExpression(new Atom("y")) }); try { expr.Evaluate(context); Assert.Fail(); } catch (System.Exception ex) { Assert.AreEqual("variable 'X' is unbound", ex.Message); } }