public void TestComplexExpression() { const string VAR_X = "x"; const string VAR_Y = "y"; const string VAR_Z = "z"; var ctx = new Context(); ctx.SetValue(VAR_X, true); ctx.SetValue(VAR_Y, true); ctx.SetValue(VAR_Z, false); var constExp = new ConstExpression(TRUE_TOKEN); var unaryExp = new UnaryExpression(constExp); Assert.AreEqual(false, unaryExp.Interpret(ctx)); var binaryExp = new BinaryExpression( new BinaryExpression(VAR_X, BinaryOp.And, unaryExp), BinaryOp.Or, new BinaryExpression(new UnaryExpression(VAR_Y), BinaryOp.And, VAR_Z)); Assert.AreEqual(false, binaryExp.Interpret(ctx)); }
public void TestConst() { var ctx = new Context(); var constExp = new ConstExpression(TRUE_TOKEN); Assert.AreEqual(true, constExp.Interpret(ctx)); constExp = new ConstExpression(FALSE_TOKEN); Assert.AreEqual(false, constExp.Interpret(ctx)); }