public Value Visit(MinusExpr expr, Scope scope) { return(PerformOperation(expr.Left.Accept(this, scope), expr.Right.Accept(this, scope), (a, b) => a - b, (a, b) => a - b, (a, b) => { throw new InvalidOperationException(); }, (a, b) => { throw new InvalidOperationException(); })); }
public void RightPropertyReturnsPassedRhsInstance() { var lhs = new ConstantExpr(1); var rhs = new ConstantExpr(2); var target = new MinusExpr(lhs, rhs); Assert.AreSame(rhs, target.Right); }
public void AcceptMethodCallsVisitOnVisitorWithThis() { var lhs = new ConstantExpr(1); var rhs = new ConstantExpr(2); var target = new MinusExpr(lhs, rhs); var visitor = new Mock <IExpressionVisitor <string, int> >(); target.Accept(visitor.Object, 0); visitor.Verify(x => x.Visit(target, 0), Times.Once); }
public void VisitMinusExpr() { var target = new EvaluateVisitor(); var lhs = new ConstantExpr(1); var rhs = new ConstantExpr(2); var expression = new MinusExpr(lhs, rhs); var actual = target.Visit(expression, _scope); Assert.AreEqual("-1", actual.ToString()); }
public void VisitMinusExpr() { var target = new PrintVisitor(); var lhs = new ConstantExpr(1); var rhs = new ConstantExpr(2); var expression = new MinusExpr(lhs, rhs); var actual = target.Visit(expression, scope); Assert.AreEqual("1-2", actual); }
public void AcceptMethodCallsVisitOnVisitorWithThis() { var lhs = new ConstantExpr(1); var rhs = new ConstantExpr(2); var target = new MinusExpr(lhs, rhs); var visitor = new Mock<IExpressionVisitor<string, int>>(); target.Accept(visitor.Object,0); visitor.Verify(x => x.Visit(target,0), Times.Once); }
public void AcceptMethodCallsOnlyVisitOnVisitorWithThisAndNoOtherVisitMethods() { var lhs = new ConstantExpr(1); var rhs = new ConstantExpr(2); var target = new MinusExpr(lhs, rhs); // throw exception is any other methods called other than the MinusExpr overload. var visitor = new Mock<IExpressionVisitor<string, int>>(MockBehavior.Strict); visitor.Setup(x => x.Visit(It.IsAny<MinusExpr>(), It.IsAny<int>())).Returns(""); target.Accept(visitor.Object,0); }
public void VisitMinusExpr() { var target = new TypeCheckingVisitor(); var lhs = new ConstantExpr(1); var rhs = new ConstantExpr(2); var expression = new MinusExpr(lhs, rhs); var actual = target.Visit(expression, scope); Assert.AreEqual(ValueType.Int, actual); }
public void AcceptMethodCallsOnlyVisitOnVisitorWithThisAndNoOtherVisitMethods() { var lhs = new ConstantExpr(1); var rhs = new ConstantExpr(2); var target = new MinusExpr(lhs, rhs); // throw exception is any other methods called other than the MinusExpr overload. var visitor = new Mock <IExpressionVisitor <string, int> >(MockBehavior.Strict); visitor.Setup(x => x.Visit(It.IsAny <MinusExpr>(), It.IsAny <int>())).Returns(""); target.Accept(visitor.Object, 0); }
/// <summary> /// Validate a minus expression. /// </summary> /// <param name="e"> /// is the expression. </param> /// <returns> null. </returns> public virtual object visit(MinusExpr e) { printUnExpr("MINUS", e); return(null); }
public string Visit(MinusExpr expr, Scope scope) { return(expr.Left.Accept(this, scope) + "-" + expr.Right.Accept(this, scope)); }
/// <param name="e"> /// is the minus expression. </param> /// <returns> new sub expression </returns> public virtual object visit(MinusExpr e) { SubExpr se = new SubExpr(make_int_lit(0), e.arg()); return(se.accept(this)); }
/// <param name="e"> /// is the minus expression. </param> /// <returns> new sub expression </returns> public virtual object visit(MinusExpr e) { e.arg().accept(this); return(null); }
public ValueType Visit(MinusExpr expr, Scope scope) { return(BinaryOperatorTypeCheck(expr, scope, numericTypesOnly: true)); }