Beispiel #1
0
        public void Clone_UnaryExpression()
        {
            //Arrange
            var expected = new UnaryExpression(OperatorTypes.Sign, new NumberExpression(0));

            //Act
            var actual = (UnaryExpression)expected.Clone();

            //Assert
            Assert.IsTrue(!Object.ReferenceEquals(actual, expected));
            Assert.AreEqual(actual.Execute().Count.Re.ToNumber(), expected.Execute().Count.Re.ToNumber());
        }
    public virtual Differences VisitUnaryExpression(UnaryExpression unaryExpression1, UnaryExpression unaryExpression2){
      Differences differences = new Differences(unaryExpression1, unaryExpression2);
      if (unaryExpression1 == null || unaryExpression2 == null){
        if (unaryExpression1 != unaryExpression2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      UnaryExpression changes = (UnaryExpression)unaryExpression2.Clone();
      UnaryExpression deletions = (UnaryExpression)unaryExpression2.Clone();
      UnaryExpression insertions = (UnaryExpression)unaryExpression2.Clone();

      if (unaryExpression1.NodeType == unaryExpression2.NodeType) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
      
      Differences diff = this.VisitExpression(unaryExpression1.Operand, unaryExpression2.Operand);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Operand = diff.Changes as Expression;
      deletions.Operand = diff.Deletions as Expression;
      insertions.Operand = diff.Insertions as Expression;
      Debug.Assert(diff.Changes == changes.Operand && diff.Deletions == deletions.Operand && diff.Insertions == insertions.Operand);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
 public override Expression VisitUnaryExpression(UnaryExpression unaryExpression){
   if (unaryExpression == null) return null;
   return base.VisitUnaryExpression((UnaryExpression)unaryExpression.Clone());
 }