public void AcceptMethodCallsVisitOnVisitorWithThis() { var name = new IdentifierExpr(RandomGenerator.String()); var arguments = new Expression[] { new ConstantExpr(RandomGenerator.Int()), new ConstantExpr(RandomGenerator.Int()) }; var target = new FunctionCallExpr(name, arguments); var visitor = new Mock <IExpressionVisitor <string, int> >(); target.Accept(visitor.Object, 0); visitor.Verify(x => x.Visit(target, 0), Times.Once); }
public void AcceptMethodCallsVisitOnVisitorWithThis() { var name = new IdentifierExpr(RandomGenerator.String()); var arguments = new Expression[] { new ConstantExpr(RandomGenerator.Int()), new ConstantExpr(RandomGenerator.Int()) }; var target = new FunctionCallExpr(name, arguments); 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 name = new IdentifierExpr(RandomGenerator.String()); var arguments = new Expression[] { new ConstantExpr(RandomGenerator.Int()), new ConstantExpr(RandomGenerator.Int()) }; var target = new FunctionCallExpr(name, arguments); // throw exception is any other methods called other than the PlusExpr overload. var visitor = new Mock <IExpressionVisitor <string, int> >(MockBehavior.Strict); visitor.Setup(x => x.Visit(target, 123)).Returns(""); target.Accept(visitor.Object, 123); }
public ValueType Visit(FunctionCallExpr functionCallExpr, Scope context) { return(functionCallExpr.Accept(this, context)); }
public void AcceptMethodCallsOnlyVisitOnVisitorWithThisAndNoOtherVisitMethods() { var name = new IdentifierExpr(RandomGenerator.String()); var arguments = new Expression[] { new ConstantExpr(RandomGenerator.Int()), new ConstantExpr(RandomGenerator.Int()) }; var target = new FunctionCallExpr(name, arguments); // throw exception is any other methods called other than the PlusExpr overload. var visitor = new Mock<IExpressionVisitor<string, int>>(MockBehavior.Strict); visitor.Setup(x => x.Visit(target, 123)).Returns(""); target.Accept(visitor.Object, 123); }