public void TestDoFoldConstantInPositiveSquareRoot()
 {
     AbstractExpr input = new UnaryExpression(Polynomial.CreateConstant(4), new PositiveSquareroot());
     IAbstractExpr result = input.Accept(visitor, Ig.nore);
     Assert.AreNotEqual(input, result);
     Assert.AreEqual(Polynomial.CreateConstant(2), result);
 }
示例#2
0
 public void Visit(UnaryExpression unaryExpression)
 {
     if (_innerVisitor != null)
     {
         unaryExpression.Accept(_innerVisitor);
     }
     unaryExpression.Right.Accept(this);
 }
 public override void Visit(UnaryExpression expression)
 {
     expression.Accept(this);
 }
 public void TestDontFoldConstantInFormalSquareRoot()
 {
     AbstractExpr input = new UnaryExpression(Polynomial.CreateConstant(4), new FormalSquareroot());
     IAbstractExpr result = input.Accept(visitor, Ig.nore);
     Assert.AreEqual(input, result);
     Assert.AreSame(input, result);
 }
 public void TestSquareOfUnaryMinus()
 {
     AbstractExpr input = new UnaryExpression(-Polynomial.CreateNamedVariable("a").C, new Square());
     string result = input.Accept(new ToStringVisitor(), BASE_PAR);
     Assert.AreEqual("(-a)²", result);
 }
 public void TestSquareOfSum()
 {
     AbstractExpr input = new UnaryExpression(Polynomial.CreateNamedVariable("a").C + Polynomial.CreateConstant(1), new Square());
     string result = input.Accept(new ToStringVisitor(), BASE_PAR);
     Assert.AreEqual("(a+1)²", result);
 }
 public void TestSinOfUnaryMinus()
 {
     AbstractExpr input = new UnaryExpression(-Polynomial.CreateConstant(1).C, new Sin());
     string result = input.Accept(new ToStringVisitor(), BASE_PAR);
     Assert.AreEqual("sin (-1)", result);
 }
 public void TestSinOfSquare()
 {
     AbstractExpr input = new UnaryExpression(new UnaryExpression(Polynomial.CreateNamedVariable("a"), new Square()), new Sin());
     string result = input.Accept(new ToStringVisitor(), BASE_PAR);
     Assert.AreEqual("sin a²", result);
 }
示例#9
0
        public void VisitorWithReturnIsImplemented()
        {
            var sut = new UnaryExpression();

            sut.Accept(23).VerifyWithReturn(v => v.Visit(sut, 23));
        }