Inheritance: Tools.TOKEN
Beispiel #1
0
        public static void Is(Not values, string s, string name)
        {
            if ((values & Not.Null) == Not.Null)
            {
                if (s == null)
                {
                    throw new ArgumentNullException(name);
                }
            }

            if ((values & Not.Empty) == Not.Empty)
            {
                if (s != null && s.Length.Equals(0))
                {
                    throw new ArgumentException("Value cannot be empty.", name);
                }
            }

            if ((values & Not.Whitespace) == Not.Whitespace)
            {
                if ((!string.IsNullOrEmpty(s)) && (s.Trim().Length == 0))
                {
                    throw new ArgumentException("Value cannot be whitespace.", name);
                }
            }
        }
Beispiel #2
0
 public void DoubleNot()
 {
     INode root = new Not(new Not(VariableNode.Make<bool>(0, "x")));
     Assert.AreEqual(
         VariableNode.Make<bool>(0, "x").ToString(),
         SimplifyLogicTree(root).ToString());
 }
Beispiel #3
0
 public void Parse(ExpressionParserHelper parseHelper)
 {
     Token token = parseHelper.Current;
     parseHelper.Expect(nameof(NotParser), NOT_SIGN, ADDITIONAL_SIGN);
     parseHelper.ParseExpression();
      var not = new Not(parseHelper.Pop());
     not.Token = token;
     parseHelper.Push(not);
 }
        public void ThenResolveReturnsFalse()
        {
            var testObject = new object();
            var expression = new Mock<IExpression>();
            var expressions = new List<IExpression> { new Mock<IExpression>().Object, expression.Object };
            expression.Setup(x => x.Resolve(testObject, expressions)).Returns(true);

            var subject = new Not(1);
            var result = subject.Resolve(testObject, expressions);

            Assert.That(result, Is.False);
        }
 public void Visit(Not not)
 {
     _sb.Append("~");
     not.Operand.Accept(this);
 }
 public virtual void Visit(Not node)
 {
 }
 public void Visit(Not not)
 {
     // Nothing to do here...
 }
Beispiel #8
0
        public override AstNode VisitNot(Not ast)
        {
            Visit(ast.Operand);

            if (ast.Operand.ExpressionType != PrimaryType.Boolean)
            {
                m_errorManager.AddError(c_SE_UnaryOpTypeInvalid, ast.OpSpan, "!", ast.Operand.ExpressionType.Name);
            }

            ast.ExpressionType = PrimaryType.Boolean;

            return ast;
        }
 //        throws jjtraveler.VisitFailure
 public virtual void testNotOnFailure()
 {
     Not not = new Not(new Fail());
     IVisitable resultNode = not.visit(n0);
     Assertion.AssertEquals(n0,resultNode);
 }
Beispiel #10
0
 public void Visit(Not not)
 {
     _instructions.Add(Instruction.Create(OpCodes.Ldc_I4_1));
     not.Operand.Accept(this);
     _instructions.Add(Instruction.Create(OpCodes.Sub));
 }
 void UnaryOperator(out Expression exp)
 {
     Token tok = null; string op = null;
     if (la.kind == 41 || la.kind == 45 || la.kind == 46) {
     if (la.kind == 41) {
         Get();
         tok = t; op = t.val;
     } else if (la.kind == 45) {
         Get();
         tok = t; op = t.val;
     } else {
         Get();
         tok = t; op = t.val;
     }
     }
     Terminal(out exp);
     if (op == "-") {
     if (!ExpectInt(exp, tok, true)) { return; }
     exp = new UnaryMinus((TypedExpression<int>)exp);
     } else if (op == "~") {
     if (!ExpectInt((TypedExpression<int>)exp, tok, true)) { return; }
     exp = new OnesComplement((TypedExpression<int>)exp);
     } else if (op == "not") {
     if (!ExpectBool(exp, tok, true)) { return; }
     exp = new Not((TypedExpression<bool>)exp);
     }
 }
 private Node factor()
 {
     Node n = Literal();
     while (_tokens.Current is NotOperator)
     {
         Not not = new Not(_tokens.Current);
         not.left = n;
         n = not;
         _tokens.MoveNext();
     }
     return n;
 }
 /// <summary>
 /// Gets the search filter instance.
 /// </summary>
 /// <param name="localName">Name of the local.</param>
 /// <returns></returns>
 private static SearchFilter GetSearchFilterInstance(string localName)
 {
     SearchFilter searchFilter;
     switch (localName)
     {
         case XmlElementNames.Exists:
             searchFilter = new Exists();
             break;
         case XmlElementNames.Contains:
             searchFilter = new ContainsSubstring();
             break;
         case XmlElementNames.Excludes:
             searchFilter = new ExcludesBitmask();
             break;
         case XmlElementNames.Not:
             searchFilter = new Not();
             break;
         case XmlElementNames.And:
             searchFilter = new SearchFilterCollection(LogicalOperator.And);
             break;
         case XmlElementNames.Or:
             searchFilter = new SearchFilterCollection(LogicalOperator.Or);
             break;
         case XmlElementNames.IsEqualTo:
             searchFilter = new IsEqualTo();
             break;
         case XmlElementNames.IsNotEqualTo:
             searchFilter = new IsNotEqualTo();
             break;
         case XmlElementNames.IsGreaterThan:
             searchFilter = new IsGreaterThan();
             break;
         case XmlElementNames.IsGreaterThanOrEqualTo:
             searchFilter = new IsGreaterThanOrEqualTo();
             break;
         case XmlElementNames.IsLessThan:
             searchFilter = new IsLessThan();
             break;
         case XmlElementNames.IsLessThanOrEqualTo:
             searchFilter = new IsLessThanOrEqualTo();
             break;
         default:
             searchFilter = null;
             break;
     }
     return searchFilter;
 }
Beispiel #14
0
 public void TestSimpleNegateOfTrue()
 {
     var not = new Not(new Property("True"));
     Assert.That(not.Evaluate(new Reflection(this)), Is.EqualTo(false));
 }
Beispiel #15
0
        public override AstNode VisitNot(Not ast)
        {
            Visit(ast.Operand);

            m_ilgen.Emit(OpCodes.Ldc_I4_0);
            m_ilgen.Emit(OpCodes.Ceq);

            return ast;
        }
 //    throws jjtraveler.VisitFailure
 public virtual void testNotOnSuccess()
 {
     Not not = new Not(new Identity());
     IVisitable resultNode = null;
     try
     {
         resultNode = not.visit(n0);
         Assertion.Fail("VisitFailure should have occured");
     }
     catch (VisitFailure)
     {
         Assertion.AssertNull(resultNode);
     }
 }
 public void Visit(Not not)
 {
     not.Operand.Accept(this);
     not.Type = MustBeBool(string.Format("The operand of {0} must be bool", not));
 }
Beispiel #18
0
	void Awake()
	{
		node = new Not(null);
		child.OnSlotFilled += ChildFilled;
	}
Beispiel #19
0
	public void Negate()
	{
		Not newRoot = new Not(root);
		root = newRoot;
	}