Example #1
0
        public override Value Visit(NotEqual node)
        {
            Value left  = node.Left().Accept(this);
            Value right = node.Right().Accept(this);

            return(left.BoolNotEqual((dynamic)right));
        }
Example #2
0
        public void NumberEqualTest()
        {
            var equal  = new NotEqual(new Number(11), new Number(10));
            var result = (bool)equal.Execute();

            Assert.True(result);
        }
        public bool CompareShouldBeAffectedIgnoreCase(string left, string right, bool ignoreCase)
        {
            var expression = Expression.Constant("");

            var result = new NotEqual<CustomEntity>("!=", ignoreCase).Compare(expression, OperandBuilder.BuildUp(left), OperandBuilder.BuildUp(right));
            return (bool)Expression.Lambda(result.Expression).Compile().DynamicInvoke();
        }
Example #4
0
        public void BoolTrueAndFalseEqualTest()
        {
            var equal  = new NotEqual(new Bool(true), new Bool(false));
            var result = (bool)equal.Execute();

            Assert.True(result);
        }
Example #5
0
        public Value Visit(NotEqual node)
        {
            Value left  = node.Left().Accept(this);
            Value right = node.Right().Accept(this);

            return(left.NotEqual(right));
        }
Example #6
0
        public void BoolFalseEqualTest()
        {
            var equal  = new NotEqual(new Bool(false), new Bool(false));
            var result = (bool)equal.Execute();

            Assert.Equal(false, result);
        }
Example #7
0
        public void CloneTest()
        {
            var exp   = new NotEqual(new Number(2), new Number(2));
            var clone = exp.Clone();

            Assert.Equal(exp, clone);
        }
Example #8
0
        public void Visit(NotEqual op)
        {
            var left  = VisitChild(op.Variable);
            var right = VisitChild(op.Literal);

            _codeStack.Peek().Expression = new CodeBinaryOperatorExpression(left.Expression, CodeBinaryOperatorType.IdentityInequality, right.Expression);
        }
        private ComparisonOperator ComparisonOperator()
        {
            if (this.lexer.Token == null || !this.lexer.Token.Is(TokenType.Name))
            {
                this.SyntaxError("comparision operator");
            }

            ComparisonOperator comparisonOperator = null;

            switch (this.lexer.Token.Value)
            {
            case "pr":
                comparisonOperator = new Present();
                break;

            case "eq":
                comparisonOperator = new Equal();
                break;

            case "ne":
                comparisonOperator = new NotEqual();
                break;

            case "co":
                comparisonOperator = new Contains();
                break;

            case "sw":
                comparisonOperator = new StartsWith();
                break;

            case "ew":
                comparisonOperator = new EndsWith();
                break;

            case "gt":
                comparisonOperator = new GreaterThan();
                break;

            case "lt":
                comparisonOperator = new LessThan();
                break;

            case "ge":
                comparisonOperator = new GreaterThanOrEqual();
                break;

            case "le":
                comparisonOperator = new LessThanOrEqual();
                break;

            default:
                this.SyntaxError("comparision operator");
                break;
            }

            this.Match(this.lexer.Token.Name);
            return(comparisonOperator);
        }
Example #10
0
 public void Visit(NotEqual n)
 {
     Helpers.Write("(");
     n.LeftExpression.Accept(this);
     Helpers.Write(" != ");
     n.RightExpression.Accept(this);
     Helpers.Write(")");
 }
Example #11
0
 public override bool Visit(NotEqual node)
 {
     traverse(node.left);
     outputCode(" != ", false, false);
     traverse(node.right);
     //Visit((LogicalBinaryExpression) node);
     return(true);
 }
Example #12
0
        public bool CompareShouldBeAffectedIgnoreCase(string left, string right, bool ignoreCase)
        {
            var expression = Expression.Constant("");

            var result = new NotEqual <CustomEntity>("!=", ignoreCase).Compare(expression, OperandBuilder.BuildUp(left), OperandBuilder.BuildUp(right));

            return((bool)Expression.Lambda(result.Expression).Compile().DynamicInvoke());
        }
Example #13
0
 /// <summary>
 /// Initializes the <see cref="Ops" /> class.
 /// </summary>
 static Ops()
 {
     Equal              = new Equal();
     GreaterThan        = new GreaterThan();
     GreaterThanOrEqual = new GreaterThanOrEqual();
     LessThan           = new LessThan();
     LessThanOrEqual    = new LessThanOrEqual();
     NotEqual           = new NotEqual();
 }
Example #14
0
        /// <summary>
        /// Analyzes the specified expression.
        /// </summary>
        /// <param name="exp">The expression.</param>
        /// <returns>The result of analysis.</returns>
        public string Analyze(NotEqual exp)
        {
            if (exp.Parent is BinaryExpression && !(exp.Parent is While))
            {
                return(ToString(exp, "({0} != {1})"));
            }

            return(ToString(exp, "{0} != {1}"));
        }
Example #15
0
        public void NotEqual_WithString3Double3_ReturnsFalse()
        {
            var left  = new Constant("3");
            var right = new Constant(3.0);

            var operation = new NotEqual(left, right);
            var actual    = (bool)operation.GetExpression(null).Calculate();

            Assert.AreEqual(false, actual);
        }
Example #16
0
 //-----------------------------------------------------------
 public string Visit(NotEqual node, Table table)
 {
     return(String.Format(
                "{0}{1}"
                + "\t\tceq\n"
                + "\t\tldc.i4.0\n"
                + "\t\tceq\n",
                Visit((dynamic)node[0], table),
                Visit((dynamic)node[1], table)));
 }
Example #17
0
        public static ICriteria <T> NotEqual <T>(this IPredicate <T> predicate, object value)
        {
            var root      = (IRestorableQuery <T>)predicate;
            var @operator = new NotEqual();
            var criteria  = new SingleCriteria <T>(root.RootQuery, predicate, @operator, value);

            root.RootQuery.Criterias.Add(criteria);

            return(criteria);
        }
        public void Evaluate_NotEqual_String_False_Test()
        {
            Expression left  = CreateStringLiteral("notEqual");
            Expression right = CreateStringLiteral("notEqual");

            Expression notEqual = new NotEqual(left, right, pos);

            Values.Bool value = ((Values.Bool)notEqual.Accept(evaluator));

            Assert.IsFalse(value.GetValue());
        }
Example #19
0
        /// <summary>
        /// ステータスをチェック:ステータスが存在しない場合は falseを返す
        /// </summary>
        /// <param name="stsmgr"></param>
        /// <returns></returns>
        public bool CheckStatus(IStatusManager stsmgr)
        {
            if (_op == null && Status != null)
            {
                _op = new And();

                var coa = Status.Split('&', StringSplitOptions.RemoveEmptyEntries);
                foreach (var a in coa)
                {
                    var idx = a.IndexOf("!=");
                    if (idx >= 0)
                    {
                        var eq = new NotEqual
                        {
                            StatusName  = StrUtil.Left(a, idx).Trim(),
                            StatusValue = StrUtil.Mid(a, idx + 2),
                        };
                        _op.Commands.Add(eq);
                        continue;
                    }
                    idx = a.IndexOf("=");
                    if (idx >= 0)
                    {
                        var eq = new Equal
                        {
                            StatusName  = StrUtil.Left(a, idx).Trim(),
                            StatusValue = StrUtil.Mid(a, idx + 1).Trim(),
                        };
                        _op.Commands.Add(eq);
                        continue;
                    }
                    else
                    {
                        if (a.Trim().StartsWith('!'))
                        {
                            _op.Commands.Add(new Equal
                            {
                                StatusName  = a.Trim().Substring(1),
                                StatusValue = "False",
                            });
                        }
                        else
                        {
                            _op.Commands.Add(new NotEqual
                            {
                                StatusName  = a.Trim(),
                                StatusValue = "False",
                            });
                        }
                    }
                }
            }
            return(_op?.Check(stsmgr) ?? false);
        }
Example #20
0
        protected virtual Expression OnVisit(NotEqual expression)
        {
            var left  = OnVisit(expression.Left);
            var right = OnVisit(expression.Right);

            if (left != expression.Left || right != expression.Right)
            {
                return(CopyTrivia(new NotEqual(left, right), expression));
            }
            return(expression);
        }
        public void Evaluate_NotEqual_Int_True_Test()
        {
            Expression left  = CreateIntLiteral(1);
            Expression right = CreateIntLiteral(2);

            Expression notEqual = new NotEqual(left, right, pos);

            Values.Bool value = ((Values.Bool)notEqual.Accept(evaluator));

            Assert.IsTrue(value.GetValue());
        }
Example #22
0
        public void NumberAndBoolVarEqualTest()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", 10),
                new Parameter("y", false)
            };
            var equal = new NotEqual(Variable.X, new Variable("y"));

            Assert.Throws <NotSupportedException>(() => equal.Execute(parameters));
        }
Example #23
0
        public void BoolTrueAndFalseVarEqualTest()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", true),
                new Parameter("y", false)
            };
            var equal  = new NotEqual(Variable.X, new Variable("y"));
            var result = (bool)equal.Execute(parameters);

            Assert.True(result);
        }
Example #24
0
        public void BoolFalseVarEqualTest()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", false),
                new Parameter("y", false)
            };
            var equal  = new NotEqual(new Variable("x"), new Variable("y"));
            var result = (bool)equal.Execute(parameters);

            Assert.Equal(false, result);
        }
Example #25
0
        public void NumberVarEqualTest()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", 11),
                new Parameter("y", 10)
            };
            var equal  = new NotEqual(Variable.X, new Variable("y"));
            var result = (bool)equal.Execute(parameters);

            Assert.True(result);
        }
Example #26
0
 public StringFilter ToUpper()
 {
     Equal        = Equal?.ToUpper();
     NotEqual     = NotEqual?.ToUpper();
     Contain      = Contain?.ToUpper();
     NotContain   = NotContain?.ToUpper();
     StartWith    = StartWith?.ToUpper();
     NotStartWith = NotStartWith?.ToUpper();
     EndWith      = EndWith?.ToUpper();
     NotEndWith   = NotEndWith?.ToUpper();
     return(this);
 }
Example #27
0
        static RuleSet CreateRuleset(string rulesetName)
        {
            // create a simple rule
            // IF MySampleBusinessObject.MyValue != XMLdocument.ID
            // THEN MySampleBusinessObject.MySampleMethod1(5)

            //Creating the XML bindings on the SampleSchema XSD

            //Document Binding that binds to the schema name and specifies the selector
            XPathPair          xp_root = new XPathPair("/*[local-name()='Root']", "Root");
            XMLDocumentBinding xdb     = new XMLDocumentBinding("SampleSchema", xp_root);

            //DocumentField Bindings that bind to the fields in the schema that need to be used in rule defintion
            XPathPair xp_ID = new XPathPair("/*[local-name()='Root']/*[local-name()='ID']", "ID");
            XMLDocumentFieldBinding xfb1 = new XMLDocumentFieldBinding(Type.GetType("System.Int32"), xp_ID, xdb);

            //Creating .NET class (property and member) bindings

            // Class Bindings to bind to the class defintions whose properties and memebers will be used in rule defintion
            ClassBinding cb = new ClassBinding(typeof(Microsoft.Samples.BizTalk.BusinessRulesHelloWorld2.HelloWorld2Library.HelloWorld2LibraryObject));

            // Member Bindings to bind to the properties and members in the MySampleBusinessObject class that need to be used in rule definition
            ClassMemberBinding myValue = new ClassMemberBinding("MyValue", cb);

            ArgumentCollection argList = new ArgumentCollection();

            argList.Add(new Constant(5));
            ClassMemberBinding method1 = new ClassMemberBinding("MySampleMethod", cb, argList);


            // create IF part
            LogicalExpression condition = new NotEqual(new UserFunction(myValue), new UserFunction(xfb1));

            // create then part
            ActionCollection actions = new ActionCollection();

            actions.Add(new UserFunction(method1));

            // create the rule
            Rule rule1 = new Rule("rule1", 0, condition, actions);

            //create the verion information and ruleset description

            DateTime    time  = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.Now.Day);
            VersionInfo vinf1 = new VersionInfo("Sample RuleSet to demonstrate the use of the Policy object", time, "BizRules", 1, 0);

            // create the ruleset
            RuleSet rs1 = new RuleSet(rulesetName, vinf1);

            rs1.Rules.Add(rule1);
            return(rs1);
        }
        public SemanticAtom Visit(NotEqual n)
        {
            var left  = n.LeftExpression.Accept(this) as SemanticType;
            var right = n.RightExpression.Accept(this) as SemanticType;

            if (!left.IsAssignableFrom(right) && !right.IsAssignableFrom(left))
            {
                Globals.Errors.Add($"[{n.LeftExpression.Location.StartLine}, {n.LeftExpression.Location.StartColumn}] The two expressions of (!=) are not comparable types ({left.Name}, {right.Name}).");
            }

            n.RealizedType = Primitive.Boolean;
            return(n.RealizedType);
        }
        public string Visit(NotEqual node)
        {
            var result = "\t\tldc.i4 42\n";

            result += Visit((dynamic)node[0]);
            result += Visit((dynamic)node[1]);
            var labelSuccess = GenerateLabel();

            result += "\t\tbne.un " + labelSuccess + "\n";
            result += "\t\tpop\n";
            result += "\t\tldc.i4 0\n";
            result += "\t\t" + labelSuccess + ":\n";
            return(result);
        }
        public void Visit(NotEqual n)
        {
            Helpers.WriteLine($"{_tab}{n.Text} [{n.Location.StartLine}, {n.Location.StartColumn}]");
            Tab();

            Helpers.WriteLine($"{_tab}Left");
            Tab();
            n.LeftExpression.Accept(this);
            Untab();
            Helpers.WriteLine($"{_tab}Right");
            Tab();
            n.RightExpression.Accept(this);
            Untab();

            Untab();
        }
Example #31
0
        public override void VisitNotEqual(NotEqual n)
        {
            SetupOperands(n);
            if (_lastWalkedType == typeof(String))
            {
                _gen.Emit(OpCodes.Call, typeof(String).GetMethod("Equals", BindingFlags.Public | BindingFlags.Static, null,
                                                                 new Type[] { typeof(string), typeof(string) }, null));
            }
            else
            {
                _gen.Emit(OpCodes.Ceq);
            }
            //compare it with 0 to negate
            _gen.Emit(OpCodes.Ldc_I4_0);
            _gen.Emit(OpCodes.Ceq);

            _lastWalkedType = typeof(bool);
        }
Example #32
0
 public void SetUp()
 {
     testee = new NotEqual<CustomEntity>("!=");
 }
        void Comparison(out Expression exp)
        {
            Expression second;
            BitOr(out exp);
            if (StartOf(3)) {
            switch (la.kind) {
            case 29: {
                Get();
                break;
            }
            case 30: {
                Get();
                break;
            }
            case 31: {
                Get();
                break;
            }
            case 32: {
                Get();
                break;
            }
            case 33: {
                Get();
                break;
            }
            case 34: {
                Get();
                break;
            }
            }
            Token tok = t;
            Comparison(out second);
            if (!ExpectInt(exp, tok, false)) { return; };
            if (!ExpectInt(second, tok, true)) { return; };
            if (tok.val == "<") {
                exp = new LessThan((TypedExpression<int>)exp, (TypedExpression<int>)second);
            } else if (tok.val == ">") {
                exp = new GreaterThan((TypedExpression<int>)exp, (TypedExpression<int>)second);
            } else if (tok.val == "<=") {
                exp = new LessThanOrEqual((TypedExpression<int>)exp, (TypedExpression<int>)second);
            } else if (tok.val == ">=") {
                exp = new GreaterThanOrEqual((TypedExpression<int>)exp, (TypedExpression<int>)second);
            } else if (tok.val == "==") {
                exp = new Equal((TypedExpression<int>)exp, (TypedExpression<int>)second);
            } else if (tok.val == "!=") {
                exp = new NotEqual((TypedExpression<int>)exp, (TypedExpression<int>)second);
            }

            }
        }
 public void NotEqualCorrectlyConvertsToJson()
 {
     var neq = new NotEqual<string>("foo");
     neq.ToString().ShouldEqual(NotEqualJson);
 }
Example #35
0
 public virtual void Visit(NotEqual node)
 {
 }
Example #36
0
 public virtual void VisitNotEqual(NotEqual n)
 {
 }