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); } }
public void Evaluate_RightIsNull_ReturnsFalse() { var equals = new Equals(new Integer(5), Null.Instance); var result = equals.EvaluateWithData <bool>(); Assert.False(result); }
public override string visit(Equals equals) { string sToSplit = base.visit(equals); this.addtodic(sToSplit); return(sToSplit); }
public void Evaluate_LeftAndRightIAreNull_ReturnsTrue() { var equals = new Equals(Null.Instance, Null.Instance); var result = equals.EvaluateWithData <bool>(); Assert.True(result); }
//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(); }
public object Visit(Equals expression) { object leftValue = expression.Left.Accept <object>(this); object rightValue = expression.Right.Accept <object>(this); return((int)leftValue == (int)rightValue); }
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); } }
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); } } }
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()); }
public void Visit(Equals bin) { var left = bin.Left; var right = bin.Right; PrepareBinaryOperation(left, right); EmitStackDown("ceq"); }
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>(); }
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(); }
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(); }
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); }
public void TestEquals() { Equals equals = new Equals { LeftHand = new Boolean(true), RightHand = new Boolean(false) }; Assert.False(equals.Execute()); }
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(); }
//----------------------------------------------------------- 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 )); }
public void Number() { var sut = new Equals <int>(3); sut.Get(4) .Should() .BeFalse(); sut.Get(3) .Should() .BeTrue(); }
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(); } }
public void Object() { var source = new object(); var sut = new Equals <object>(source); sut.Get(new object()) .Should() .BeFalse(); sut.Get(source) .Should() .BeTrue(); }
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); }
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! }
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); }
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); } }
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)); }
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); }
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); } }
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(); }
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); }
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); }
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); }
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); } } }
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; }
public override string visit(Equals equals) { string sToSplit = base.visit(equals); this.addtodic(sToSplit); return sToSplit; }