コード例 #1
0
        public void TestThenNotExecuted()
        {
            Equals equals = new Equals
            {
                LeftHand  = new ARPB2Engine.Model.Boolean(true),
                RightHand = new ARPB2Engine.Model.Boolean(false)
            };

            void Print(string str)
            {
                var res = str + "a";

                Assert.True(false, "Called when it shouldn't");
            }

            If @if = new If();

            @if.conditions.Add(equals);
            try
            {
                @if.ExecuteHandler(Print, "a");
            }
            catch (Exception ex)
            {
                // There is no Assert.Fail in xUnit
                Assert.True(false, "Expected no exception, but got: " + ex.Message);
            }
        }
コード例 #2
0
ファイル: EqualsTest.cs プロジェクト: thomicdk/HypnoGreen
        public void Evaluate_RightIsNull_ReturnsFalse()
        {
            var equals = new Equals(new Integer(5), Null.Instance);
            var result = equals.EvaluateWithData <bool>();

            Assert.False(result);
        }
コード例 #3
0
        public override string visit(Equals equals)
        {
            string sToSplit = base.visit(equals);

            this.addtodic(sToSplit);
            return(sToSplit);
        }
コード例 #4
0
ファイル: EqualsTest.cs プロジェクト: thomicdk/HypnoGreen
        public void Evaluate_LeftAndRightIAreNull_ReturnsTrue()
        {
            var equals = new Equals(Null.Instance, Null.Instance);
            var result = equals.EvaluateWithData <bool>();

            Assert.True(result);
        }
コード例 #5
0
        //sample: filtered list method for the Workflow General/Process Instance SmartObject
        static void ExecuteFilteredListMethodWCF()
        {
            Console.WriteLine("Executing filtered List method via WCF (Active instances only)");
            //set up the service client
            WorkflowGeneralReport_WCFService.Process_InstanceSvcClient processInstanceSvcClient = new Process_InstanceSvcClient();
            processInstanceSvcClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

            //set up a filter object (you could also constrcut the filter directly in XML if you prefer)
            Equals             statusEquals      = new Equals();
            PropertyExpression statusPropertyExp = new PropertyExpression("Status", PropertyType.Text);
            ValueExpression    statusValueExp    = new ValueExpression("Active", PropertyType.Text);

            statusEquals.Left  = statusPropertyExp;
            statusEquals.Right = statusValueExp;

            // Serialize the filter to XML
            FilterExp   filterExpression = new FilterExp(statusEquals);
            XmlDocument filterXml        = filterExpression.GetFilterXml();
            string      filterXmlString  = filterXml.InnerXml;

            //call the filter method, passing in the filter XML
            WorkflowGeneralReport_WCFService.Process_Instance[] processInstanceList = processInstanceSvcClient.Process_InstanceSvc_List_Filtered(filterXmlString);
            foreach (Process_Instance processInstance in processInstanceList)
            {
                Console.WriteLine("Folio: " + processInstance.Folio + " | ProcInstID: " + processInstance.ProcessInstanceID.ToString());
            }
            Console.WriteLine("Completed execution of filtered List method via WCF (Active instances only)");
            Console.ReadLine();
        }
コード例 #6
0
        public object Visit(Equals expression)
        {
            object leftValue  = expression.Left.Accept <object>(this);
            object rightValue = expression.Right.Accept <object>(this);

            return((int)leftValue == (int)rightValue);
        }
コード例 #7
0
        public void TestIf()
        {
            Equals equals = new Equals
            {
                LeftHand  = new ARPB2Engine.Model.Boolean(true),
                RightHand = new ARPB2Engine.Model.Boolean(true)
            };

            void Print(string str)
            {
                var res = str + "a";

                Assert.True(res == "aa"); // Seems redundant but it's a workaround to test this delegate was called
            }

            If @if = new If();

            @if.conditions.Add(equals);
            try
            {
                @if.ExecuteHandler(Print, "a");
            }
            catch (Exception ex)
            {
                // There is no Assert.Fail in xUnit
                Assert.True(false, "Expected no exception, but got: " + ex.Message);
            }
        }
コード例 #8
0
ファイル: SqlExtensions.cs プロジェクト: t1b1c/lwas
        public static void ToSql(Equals expression, StringBuilder builder)
        {
            if (null == expression)
            {
                throw new ArgumentNullException("expression");
            }
            if (null == builder)
            {
                throw new ArgumentNullException("builder");
            }

            if (expression.Operands.Count > 0)
            {
                IToken operand1 = expression.Operands
                                  .First();
                IToken operand2 = expression.Operands
                                  .ElementAtOrDefault(1);
                if (null != operand1 && null != operand2)
                {
                    operand1.ToSql(builder);
                    builder.Append(" = ");
                    operand2.ToSql(builder);
                }
            }
        }
コード例 #9
0
        public static string GetEqualsOperand(Equals expression, VHDLCompilerInterface compiler)
        {
            string left  = GetOperand(expression.Left, compiler);
            string right = GetOperand(expression.Right, compiler);
            FunctionCallTemplate template = new FunctionCallTemplate(left, "Equals", right);

            return(template.TransformText());
        }
コード例 #10
0
        public void Visit(Equals bin)
        {
            var left  = bin.Left;
            var right = bin.Right;

            PrepareBinaryOperation(left, right);

            EmitStackDown("ceq");
        }
コード例 #11
0
ファイル: DragAndDrop.cs プロジェクト: Wahale/Pick
 private void Awake()
 {
     equals        = GameObject.Find("Container").GetComponent <Equals>();
     rectTransform = GetComponent <RectTransform>();
     canvasGroup   = GetComponent <CanvasGroup>();
     collider2d    = GetComponent <BoxCollider2D>();
     canvas        = GameObject.Find("Canvas").GetComponent <Canvas>();
     spawnItem     = GameObject.Find("Container").GetComponent <SpawnItemInSlot>();
 }
コード例 #12
0
        public void Five_should_not_equal_six()
        {
            var expression = new Equals <int>
            {
                Child1 = new Constant <int>(5),
                Child2 = new Constant <int>(6)
            };

            expression.Evaluate(new MockAiContext()).ShouldBeFalse();
        }
コード例 #13
0
        public void True_should_equal_true()
        {
            var expression = new Equals <bool>
            {
                Child1 = new Constant <bool>(true),
                Child2 = new Constant <bool>(true)
            };

            expression.Evaluate(new MockAiContext()).ShouldBeTrue();
        }
コード例 #14
0
ファイル: EqualsTest.cs プロジェクト: thomicdk/HypnoGreen
        public void Evaluate_LeftIsNotEqualToRight_ReturnsFalse()
        {
            var left   = new Integer(-1);
            var right  = new Integer(3934);
            var equals = new Equals(left, right);

            var result = equals.EvaluateWithData <bool>();

            Assert.False(result);
        }
コード例 #15
0
        public void TestEquals()
        {
            Equals equals = new Equals
            {
                LeftHand  = new Boolean(true),
                RightHand = new Boolean(false)
            };

            Assert.False(equals.Execute());
        }
コード例 #16
0
        public void Six_should_equal_six()
        {
            var equals = new Equals <int>
            {
                Child1 = new Constant <int>(6),
                Child2 = new Constant <int>(6)
            };

            equals.Evaluate(new MockAiContext()).ShouldBeTrue();
        }
コード例 #17
0
        //-----------------------------------------------------------
        public string Visit(Equals node)
        {
            var label = GenerateLabel();

            return(String.Format(
                       "\t\tldc.i4 42\n\t\t{0}\n\t\t{1}\n\t\tbeq '{2}'\n\t\tpop\n\t\tldc.i4.0\n\t'{2}':\n",
                       Visit((dynamic)node[0]),
                       Visit((dynamic)node[1]),
                       label
                       ));
        }
コード例 #18
0
        public void Number()
        {
            var sut = new Equals <int>(3);

            sut.Get(4)
            .Should()
            .BeFalse();
            sut.Get(3)
            .Should()
            .BeTrue();
        }
コード例 #19
0
 private void Calculator_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         Equals.PerformClick();
     }
     if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
     {
         this.performBackspace();
     }
 }
コード例 #20
0
        public void Object()
        {
            var source = new object();
            var sut    = new Equals <object>(source);

            sut.Get(new object())
            .Should()
            .BeFalse();
            sut.Get(source)
            .Should()
            .BeTrue();
        }
コード例 #21
0
    public static void AddOnlyOnce <T> (this List <T> list, T element, Equals <T> comparer)
    {
        for (int i = 0; i < list.Count; i++)
        {
            T listElement = list[i];
            if (comparer(listElement, element))
            {
                return;
            }
        }

        list.Add(element);
    }
コード例 #22
0
    public static void Main(string[] args)
    {
        Equals eN = null;
        Equals e1 = new Equals();

        println(eN);
        println(e1);

        println("e1 eqls eN");
        println(e1.eqls(eN));

        println("eN eqls e1");
        println(eN.eqls(e1)); // NullPointerException!
    }
コード例 #23
0
        public string Visit(Equals node)
        {
            var st       = "";
            var labelOne = GenerateLabel();
            var labelTwo = GenerateLabel();

            st += VisitChildren(node);
            st += tab(2) + "bne.un " + labelOne + "\n";
            st += tab(2) + "ldc.i4.0\n";
            st += tab(2) + "br " + labelTwo + "\n";
            st += tab(1) + labelOne + ":\n";
            st += tab(2) + "ldc.i4 42\n";
            st += tab(1) + labelTwo + ":\n";
            return(st);
        }
コード例 #24
0
ファイル: Register.cs プロジェクト: cuijialang/HDL_ANTLR4
        internal override void addClockAssignments(List <SequentialStatement> statements)
        {
            SequentialStatement signalAssignment = new SignalAssignment(Name.reference(output), Name.reference(input));

            if (writeEnable != null)
            {
                Expression  writeEnableCondition = new Equals(Name.reference(writeEnable), StdLogic1164.STD_LOGIC_1);
                IfStatement writeEnableIf        = new IfStatement(writeEnableCondition);
                writeEnableIf.Statements.Add(signalAssignment);
                statements.Add(writeEnableIf);
            }
            else
            {
                statements.Add(signalAssignment);
            }
        }
コード例 #25
0
        public void EqualsTest()
        {
            var actor  = new Equals <DataModel>();
            var equals = actor.Build(infoProvider);

            Assert.IsTrue(equals(new DataModel(), new DataModel()));
            Assert.IsTrue(equals(null, null));
            Assert.IsFalse(equals(null, new DataModel()));
            Assert.IsFalse(equals(new DataModel(), null));

            var dataModel = new DataModel();

            Assert.IsTrue(equals(dataModel, dataModel));
            dataModel.Id = 2;
            Assert.IsFalse(equals(new DataModel(), dataModel));
        }
コード例 #26
0
        public object compilar(Entorno ent, Errores errores)
        {
            //VERIFICO QUE NO SEAN DE TIPO REAL
            this.validarEtiquetas(ent);
            //CREO MIS UTILIDADES (CREO UN IF CON SU RESPECTIVA CONDICION)
            //PARA LA CONDICION
            Expresion condicion;

            if (etiquetas.Count == 1)
            {
                Expresion right = etiquetas.ElementAt(0);
                Equals    igual = new Equals(variable, right, linea, columna);
                condicion = (Expresion)igual;
            }
            else   //N etiquetas creo N Or
            {
                Or     oranterior = null;
                Or     oractual   = null;
                Equals primero    = null;

                for (int i = 0; i < etiquetas.Count; i++)
                {
                    Expresion etiqueta = etiquetas.ElementAt(i);
                    if (i == 0)
                    {
                        primero = new Equals(variable, etiqueta, linea, columna);
                    }
                    else if (i == 1)
                    {
                        Equals segundo = new Equals(variable, etiqueta, linea, columna);
                        oractual = new Or(primero, segundo, linea, columna);
                    }
                    else
                    {
                        Equals nuevo = new Equals(variable, etiqueta, linea, columna);
                        oranterior = oractual;
                        oractual   = new Or(oranterior, nuevo, linea, columna);
                    }
                }
                condicion = oractual;
            }
            //PARA EL IF
            If miif = new If(condicion, sentencias, null, linea, columna);

            //COMPILACION
            return(miif);
        }
コード例 #27
0
        private void Calculator_KeyPress(object sender, KeyPressEventArgs e)
        {
            string[] validOperations = { "-", "+", "/", "*", "^" };

            string key = e.KeyChar.ToString();

            if (key == "=")
            {
                Equals.PerformClick();
            }
            else if ((String.Compare(key, "0") >= 0 && String.Compare("9", key) >= 0) || key == ".")
            {
                this.numberChangeInit(key);
            }
            else if (validOperations.Contains(key))
            {
                this.operationInit(key);
            }
        }
コード例 #28
0
        public AbstractValue Evaluate(Equals expr)
        {
            AbstractValue left  = Evaluate(expr.Left);
            AbstractValue right = Evaluate(expr.Right);

            if ((left != null) && (right != null) && (left is STD_LOGIC_VALUE) && (right is STD_LOGIC_VALUE))
            {
                return(STD_LOGIC_VALUE.EQUALS(left as STD_LOGIC_VALUE, right as STD_LOGIC_VALUE));
            }
            if ((left != null) && (right != null) && (left is TIME_VALUE) && (right is TIME_VALUE))
            {
                return(TIME_VALUE.EQUALS(left as TIME_VALUE, right as TIME_VALUE));
            }
            if ((left != null) && (right != null) && (left is TIME_VALUE) && (right is PhysicalValue))
            {
                return(TIME_VALUE.EQUALS(left as TIME_VALUE, right as PhysicalValue));
            }
            throw new NotImplementedException();
        }
コード例 #29
0
        private IExpression EqualityExpression()
        {
            var expression = RelationalExpression();

            while (lookAhead.Type == ExpressionTokenType.Equal ||
                   lookAhead.Type == ExpressionTokenType.NotEqual)
            {
                var type = lookAhead.Type;
                NextToken();
                var rightOperand = RelationalExpression();
                switch (type)
                {
                case ExpressionTokenType.Equal:
                    expression = new Equals(expression, rightOperand);
                    break;

                case ExpressionTokenType.NotEqual:
                    expression = new NotEquals(expression, rightOperand);
                    break;
                }
            }
            return(expression);
        }
コード例 #30
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        MultiStepWizards.SearchEventRegistrations.SearchBuilder =
            new SearchBuilder(Search.FromManifest(MultiStepWizards.SearchEventRegistrations.SearchManifest));



        //Add the name criteria as a contains
        SearchOperation soName = new Contains
        {
            FieldName         = "Name",
            ValuesToOperateOn = new List <object> {
                tbName.Text
            }
        };

        MultiStepWizards.SearchEventRegistrations.SearchBuilder.AddOperation(soName, SearchOperationGroupType.And);

        //Add the fee as an exact match (since it's a drop down)
        SearchOperation soFee = new Equals()
        {
            FieldName         = "Fee.Name",
            ValuesToOperateOn = new List <object> {
                ddlFee.SelectedValue
            }
        };

        MultiStepWizards.SearchEventRegistrations.SearchBuilder.AddOperation(soName, SearchOperationGroupType.And);

        string nextUrl = rblOutputFormat.SelectedValue == "download"
                     ? string.Format("~/events/SearchEventRegistrations_Results.aspx?contextID={0}&download=true", targetEvent.ID)
                     : string.Format("~/events/SearchEventRegistrations_Results.aspx?contextID={0}",
                                     targetEvent.ID);

        //Forward to results page
        GoTo(nextUrl);
    }
コード例 #31
0
ファイル: Span.cs プロジェクト: JianwenSun/cc
        private SpanPosition Set(int first, int length, object element, Equals equals, SpanPosition spanPosition)
        {
            bool inRange = FindSpan(first, spanPosition, out spanPosition);

            // fs = index of first span partly or completely updated
            // fc = character index at start of fs
            int fs = spanPosition.Index;
            int fc = spanPosition.CP;

            // Find the span that contains the first affected cp
            if (!inRange)
            {
                // The first cp is past the end of the last span
                if (fc < first)
                {
                    // Create default run up to first
                    Add(new Span(_defaultObject, first - fc));
                }

                if (   Count > 0 
                    && equals(_spans[Count-1].element, element))
                {
                    // New Element matches end Element, just extend end Element
                    _spans[Count - 1].length += length;

                    // Make sure fs and fc still agree
                    if (fs == Count)
                    {
                        fc += length;
                    }
                }
                else
                {
                    Add(new Span(element, length));
                }
            }
            else
            {
                // Now find the last span affected by the update

                int ls = fs;
                int lc = fc;
                while (   ls < Count 
                       && lc + _spans[ls].length <= first + length)
                {
                    lc += _spans[ls].length;
                    ls++;
                }
                // ls = first span following update to remain unchanged in part or in whole
                // lc = character index at start of ls

                // expand update region backwards to include existing Spans of identical
                // Element type

                if (first == fc)
                {
                    // Item at [fs] is completely replaced. Check prior item

                    if (fs > 0
                        && equals(_spans[fs - 1].element, element))
                    {
                        // Expand update area over previous run of equal classification
                        fs--;
                        fc -= _spans[fs].length;
                        first = fc;
                        length += _spans[fs].length;
                    }
                }
                else
                {
                    // Item at [fs] is partially replaced. Check if it is same as update
                    if (equals(_spans[fs].element, element))
                    {
                        // Expand update area back to start of first affected equal valued run
                        length = first + length - fc;
                        first = fc;
                    }
                }

                // Expand update region forwards to include existing Spans of identical
                // Element type

                if (   ls < Count
                    && equals(_spans[ls].element, element))
                {
                    // Extend update region to end of existing split run

                    length = lc + _spans[ls].length - first;
                    lc += _spans[ls].length;
                    ls++;
                }

                // If no old Spans remain beyond area affected by update, handle easily:

                if (ls >= Count)
                {
                    // None of the old span list extended beyond the update region

                    if (fc < first)
                    {
                        // Updated region leaves some of [fs]

                        if (Count != fs + 2)
                        {
                            if (!Resize(fs + 2))
                                throw new OutOfMemoryException();
                        }
                        _spans[fs].length = first - fc;
                        _spans[fs + 1] = new Span(element, length);
                    }
                    else
                    {
                        // Updated item replaces [fs]
                        if (Count != fs + 1)
                        {
                            if (!Resize(fs + 1))
                                throw new OutOfMemoryException();
                        }
                        _spans[fs] = new Span(element, length);
                    }
                }
                else
                {
                    // Record partial elementtype at end, if any

                    object trailingElement = null;
                    int trailingLength = 0;

                    if (first + length > lc)
                    {
                        trailingElement = _spans[ls].element;
                        trailingLength = lc + _spans[ls].length - (first + length);
                    }

                    // Calculate change in number of Spans

                    int spanDelta = 1                          // The new span
                                    + (first > fc ? 1 : 0)      // part span at start
                                    - (ls - fs);                   // existing affected span count

                    // Note part span at end doesn't affect the calculation - the run may need
                    // updating, but it doesn't need creating.

                    if (spanDelta < 0)
                    {
                        DeleteInternal(fs + 1, -spanDelta);
                    }
                    else if (spanDelta > 0)
                    {
                        Insert(fs + 1, spanDelta);
                        // Initialize inserted Spans
                        for (int i = 0; i < spanDelta; i++)
                        {
                            _spans[fs + 1 + i] = new Span(null, 0);
                        }
                    }

                    // Assign Element values

                    // Correct Length of split span before updated range

                    if (fc < first)
                    {
                        _spans[fs].length = first - fc;
                        fs++;
                        fc = first;
                    }

                    // Record Element type for updated range

                    _spans[fs] = new Span(element, length);
                    fs++;
                    fc += length;

                    // Correct Length of split span following updated range

                    if (lc < first + length)
                    {
                        _spans[fs] = new Span(trailingElement, trailingLength);
                    }
                }
            }

            // Return a known valid span position.
            return new SpanPosition(fs, fc);
        }
コード例 #32
0
ファイル: SqlExtensions.cs プロジェクト: t1b1c/lwas
        public static void ToSql(Equals expression, StringBuilder builder)
        {
            if (null == expression) throw new ArgumentNullException("expression");
            if (null == builder) throw new ArgumentNullException("builder");

            if (expression.Operands.Count > 0)
            {
                IToken operand1 = expression.Operands
                                            .First();
                IToken operand2 = expression.Operands
                                            .ElementAtOrDefault(1);
                if (null != operand1 && null != operand2)
                {
                    operand1.ToSql(builder);
                    builder.Append(" = ");
                    operand2.ToSql(builder);
                }
            }
        }
コード例 #33
0
 private Equals CreateEqualsFilter(string name, object value)
 {
     PropertyType pt;
     if (value is int)
     {
         pt = PropertyType.Number;
     }
     else if (value is string)
     {
         pt = PropertyType.Text;
     }
     else
     {
         throw new ArgumentException(string.Format("Can only cope with objects of int and string for now. Value of {0} was a {1}", name ,value.GetType()));
     }
     var filter = new Equals();
     filter.Left = new PropertyExpression(name, PropertyType.Text);
     filter.Right = new ValueExpression(value, pt);
     return filter;
 }
コード例 #34
0
 public override string visit(Equals equals)
 {
     string sToSplit = base.visit(equals);
     this.addtodic(sToSplit);
     return sToSplit;
 }