Represents a operation token.
상속: IToken
예제 #1
0
        public void EqualsSameObjectTest()
        {
            var token = new OperationToken(Operations.Multiplication);

            Assert.True(token.Equals(token));
            Assert.Equal(token, token);
        }
예제 #2
0
        public void EqualsNullTest()
        {
            var token = new OperationToken(Operations.Multiplication);

            Assert.False(token.Equals(null));
            Assert.NotEqual(null, token);
        }
예제 #3
0
        public void EqualsDiffTypeTest()
        {
            var token = new OperationToken(Operations.Multiplication);

            Assert.False(token.Equals(1));
            Assert.NotEqual((object)1, token);
        }
예제 #4
0
        public void EqualsDiffOperationTest()
        {
            var token1 = new OperationToken(Operations.Multiplication);
            var token2 = new OperationToken(Operations.Subtraction);

            Assert.False(token1.Equals(token2));
            Assert.NotEqual(token1, token2);
        }
예제 #5
0
        public void ToStringTest()
        {
            var token = new OperationToken(Operations.Multiplication);

            Assert.Equal("Operation: Multiplication", token.ToString());
        }
예제 #6
0
 /// <summary>
 /// Creates an expression object from <see cref="OperationToken"/>.
 /// </summary>
 /// <param name="token">The operation token.</param>
 /// <returns>An expression.</returns>
 protected virtual IExpression CreateOperation(OperationToken token)
 {
     switch (token.Operation)
     {
         case Operations.Addition:
             return new Add();
         case Operations.Subtraction:
             return new Sub();
         case Operations.Multiplication:
             return new Mul();
         case Operations.Division:
             return new Div();
         case Operations.Exponentiation:
             return new Pow();
         case Operations.UnaryMinus:
             return new UnaryMinus();
         case Operations.Factorial:
             return new Fact();
         case Operations.Assign:
             return new Define();
         case Operations.ConditionalAnd:
             return new Expressions.Programming.And();
         case Operations.ConditionalOr:
             return new Expressions.Programming.Or();
         case Operations.Equal:
             return new Equal();
         case Operations.NotEqual:
             return new NotEqual();
         case Operations.LessThan:
             return new LessThan();
         case Operations.LessOrEqual:
             return new LessOrEqual();
         case Operations.GreaterThan:
             return new GreaterThan();
         case Operations.GreaterOrEqual:
             return new GreaterOrEqual();
         case Operations.AddAssign:
             return new AddAssign();
         case Operations.SubAssign:
             return new SubAssign();
         case Operations.MulAssign:
             return new MulAssign();
         case Operations.DivAssign:
             return new DivAssign();
         case Operations.Increment:
             return new Inc();
         case Operations.Decrement:
             return new Dec();
         case Operations.Not:
             return new Not();
         case Operations.And:
             return new Expressions.LogicalAndBitwise.And();
         case Operations.Or:
             return new Expressions.LogicalAndBitwise.Or();
         case Operations.XOr:
             return new XOr();
         case Operations.Implication:
             return new Implication();
         case Operations.Equality:
             return new Equality();
         case Operations.NOr:
             return new NOr();
         case Operations.NAnd:
             return new NAnd();
         default:
             return null;
     }
 }
예제 #7
0
 /// <summary>
 /// Creates an expression object from <see cref="OperationToken"/>.
 /// </summary>
 /// <param name="token">The operation token.</param>
 /// <returns>An expression.</returns>
 protected virtual IExpression CreateOperation(OperationToken token)
 {
     switch (token.Operation)
     {
         case Operations.Addition:
             return new Add();
         case Operations.Subtraction:
             return new Sub();
         case Operations.Multiplication:
             return new Mul();
         case Operations.Division:
             return new Div();
         case Operations.Exponentiation:
             return new Pow();
         case Operations.UnaryMinus:
             return new UnaryMinus();
         case Operations.Factorial:
             return new Fact();
         case Operations.Assign:
             return new Define();
         case Operations.Not:
             return new Not();
         case Operations.And:
             return new And();
         case Operations.Or:
             return new Or();
         case Operations.XOr:
             return new XOr();
         default:
             return null;
     }
 }