public void TestNegation()
        {
            var op = new NegationOperator();

            var result = op.Apply(1);

            Assert.AreEqual(-1, result);
        }
        public void TestPrecedence()
        {
            var addition = new AdditionOperator();
            var subtraction = new SubtractionOperator();
            var multiplication = new MultiplicationOperator();
            var division = new DivisionOperator();
            var negation = new NegationOperator();

            Assert.IsTrue(addition.Precedence < multiplication.Precedence);
            Assert.IsTrue(addition.Precedence < division.Precedence);
            Assert.IsTrue(subtraction.Precedence < multiplication.Precedence);
            Assert.IsTrue(subtraction.Precedence < division.Precedence);
            Assert.IsTrue(multiplication.Precedence < negation.Precedence);
            Assert.IsTrue(division.Precedence < negation.Precedence);
        }
Esempio n. 3
0
        public void Evaluate()
        {
            ParserContext    pc = new ParserContext(ParserContext.DefaultBufferSize);
            FormatterContext fc = new FormatterContext(FormatterContext.DefaultBufferSize);

            NegationOperator op = new NegationOperator(new MockBooleanExpression(true));

            Assert.IsFalse(op.EvaluateParse(ref pc));
            Assert.IsFalse(op.EvaluateFormat(new StringField(3, "000000"), ref fc));

            op = new NegationOperator(new MockBooleanExpression(false));

            Assert.IsTrue(op.EvaluateParse(ref pc));
            Assert.IsTrue(op.EvaluateFormat(new StringField(3, "000000"), ref fc));
        }
Esempio n. 4
0
        public void InstantiationAndProperties()
        {
            NegationOperator op = new NegationOperator();

            Assert.IsNull(op.Expression);

            MockBooleanExpression expression = new MockBooleanExpression(true);

            op = new NegationOperator(expression);

            Assert.IsTrue(op.Expression == expression);

            op.Expression = null;

            Assert.IsNull(op.Expression);
        }
 public virtual void Visit(NegationOperator unaryOperator)
 {
     Visit(unaryOperator.Operand);
 }
Esempio n. 6
0
 public virtual T VisitNegationOperator(NegationOperator negationOperator)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
 protected Condition(NegationOperator negationOperator)
 {
     _negationOperator = negationOperator;
     SetResult(false);
 }
Esempio n. 8
0
 public override void Visit(NegationOperator unaryOperator)
 {
     Write("-");
     Visit(unaryOperator.Operand);
 }
 public string VisitNegationOperator(NegationOperator negationOperator)
 {
     throw new NotImplementedException();
 }
Esempio n. 10
0
 public AddressNode VisitNegationOperator(NegationOperator negationOperator)
 {
     throw new System.NotImplementedException();
 }