public void PUT_IndexOfContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int value) { AssumePrecondition.IsTrue(true); int Old_bhCount = bh.Count; int Old_bhCapacity = bh.Capacity; int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("old_bhMinimumKey"); int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("old_bhMinimumValue"); int Old_value = value; //code int New_Ret = bh.IndexOf(value); int New_bhCount = bh.Count; int New_bhCapacity = bh.Capacity; int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("new_bhMinimumKey"); int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("new_bhMinimumValue"); int New_value = value; PexObserve.ValueForViewing("$old_bh_count", Old_bhCount); PexObserve.ValueForViewing("$new_bh_count", New_bhCount); PexObserve.ValueForViewing("$old_bh_capacity", Old_bhCapacity); PexObserve.ValueForViewing("$new_bh_capacity", New_bhCapacity); PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey); PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey); PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue); PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue); PexObserve.ValueForViewing("$old_bh_value", Old_value); PexObserve.ValueForViewing("$new_bh_value", New_value); PexObserve.ValueForViewing("$new_ret", New_Ret); Assert.IsTrue(false); }
public void PUT_IndexOfContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int value) { // ahmad you can do this one: alternate semantics is that old ket and new key are the same; The same holds true for value AssumePrecondition.IsTrue(true); int Old_bhCount = bh.Count; int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("old_bhMinimumKey"); int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("old_bhMinimumValue"); int Old_value = value; //code int New_Ret = bh.IndexOf(value); int New_bhCount = bh.Count; int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("new_bhMinimumKey"); int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("new_bhMinimumValue"); PexObserve.ValueForViewing("$old_bh_count", Old_bhCount); PexObserve.ValueForViewing("$new_bh_count", New_bhCount); PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey); PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey); PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue); PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue); PexObserve.ValueForViewing("$old_bh_value", Old_value); PexObserve.ValueForViewing("$new_ret", New_Ret); Assert.True((((!(New_Ret == Old_bhCount)) && New_Ret <= Old_bhCount && Old_bhCount <= New_bhCount && New_bhCount <= Old_bhCount && New_Ret >= -1))); }
public void PUT_EnqueueContract([PexAssumeUnderTest] Queue.Queue <int> s1, int x) { AssumePrecondition.IsTrue(true); int Old_s1Count = s1.Count; int Old_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("old_top"); //int Old_Top = s1.Count > 0 ? s1.Peek() : x+1; //int Old_Top = PexChoose.Value<int>("old_top"); int Old_x = x; bool Old_s1ContainsX = s1.Contains(x); s1.Enqueue(x); int New_s1Count = s1.Count; int New_Top = s1.Peek(); int New_x = x; bool New_s1ContainsX = s1.Contains(x); PexObserve.ValueForViewing("$old_s1_Count", Old_s1Count); PexObserve.ValueForViewing("$new_s1_Count", New_s1Count); PexObserve.ValueForViewing("$old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); PexObserve.ValueForViewing("$old_s1_x", Old_x); PexObserve.ValueForViewing("$new_s1_x", New_x); PexObserve.ValueForViewing("$old_s1_contains_x", Old_s1ContainsX); PexObserve.ValueForViewing("$new_s1_contains_x", New_s1ContainsX); Assert.True(((New_s1ContainsX && New_s1Count == 1 + Old_s1Count && New_x == Old_x && (!(Old_Top == New_s1Count))))); }
public void PUT_PushContract([PexAssumeUnderTest] Stack.Stack <int> s1, int x) { AssumePrecondition.IsTrue(true); int Old_s1Count = s1.Count; int Old_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("old_top"); //int Old_Top = s1.Count > 0 ? s1.Peek() : x--; //int Old_Top = s1.Peek(); int Old_x = x; bool Old_s1ContainsX = s1.Contains(x); s1.Push(x); int New_s1Count = s1.Count; int New_Top = s1.Peek(); int New_x = x; bool New_s1ContainsX = s1.Contains(x); PexObserve.ValueForViewing("$old_s1_Count", Old_s1Count); PexObserve.ValueForViewing("$new_s1_Count", New_s1Count); PexObserve.ValueForViewing("$old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); PexObserve.ValueForViewing("$old_s1_x", Old_x); PexObserve.ValueForViewing("$new_s1_x", New_x); PexObserve.ValueForViewing("$Old_s1ContainsX", Old_s1ContainsX); PexObserve.ValueForViewing("$New_s1ContainsX", New_s1ContainsX); Assert.True(((New_s1ContainsX && New_s1Count == 1 + Old_s1Count && Old_x == New_Top && New_x == New_Top))); }
public void PUT_ContainsContract([PexAssumeUnderTest] Queue.Queue <int> s1, int x) { int undefinedTop = PexChoose.Value <int>("old_top"); AssumePrecondition.IsTrue(true); int Old_s1Count = s1.Count; int Old_Top = s1.Count > 0 ? s1.Peek() : undefinedTop; //bool Old_s1ContainsX = s1.Contains(x); /*Code */ bool New_Ret = s1.Contains(x); int New_s1Count = s1.Count; int New_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("new_top"); //int New_Top = s1.Count > 0 ? s1.Peek() : Old_Top; //bool New_s1ContainsX = s1.Contains(x); PexObserve.ValueForViewing("$old_s1_Count", Old_s1Count); PexObserve.ValueForViewing("$new_s1_Count", New_s1Count); PexObserve.ValueForViewing("$old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); PexObserve.ValueForViewing("$new_ret", New_Ret); //PexObserve.ValueForViewing("$old_s1_contains_x", Old_s1ContainsX); //PexObserve.ValueForViewing("$new_s1_contains_x", New_s1ContainsX); Assert.True(((New_s1Count <= Old_s1Count && Old_s1Count <= New_s1Count && (!(New_Ret)) && New_s1Count >= 0) || (New_s1Count <= Old_s1Count && Old_s1Count <= New_s1Count && Old_Top <= New_Top && New_Top <= Old_Top && New_s1Count >= 1))); }
public void PUT_ContainsContract([PexAssumeUnderTest] Stack.Stack <int> s1, int x) { int undefinedTop = PexChoose.Value <int>("old_top"); AssumePrecondition.IsTrue(true); int Old_s1Count = s1.Count; int Old_Top = s1.Count > 0 ? s1.Peek() : undefinedTop; //bool Old_Ret = PexChoose.Value<bool>("default_Ret"); bool Old_s1ContainsX = s1.Contains(x); /*Code */ bool New_Ret = s1.Contains(x); int New_s1Count = s1.Count; //int New_Top = s1.Count > 0 ? s1.Peek() : undefinedTop; int New_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("new_top"); bool New_s1ContainsX = s1.Contains(x); PexObserve.ValueForViewing("$old_s1_Count", Old_s1Count); PexObserve.ValueForViewing("$new_s1_Count", New_s1Count); PexObserve.ValueForViewing("$old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); //PexObserve.ValueForViewing("$old_s1_ret", Old_Ret); PexObserve.ValueForViewing("$new_ret", New_Ret); PexObserve.ValueForViewing("$old_s1_contains_x", Old_s1ContainsX); PexObserve.ValueForViewing("$new_s1_contains_x", New_s1ContainsX); Assert.True(((New_s1Count == Old_s1Count))); }
public void PUT_RemoveMinimumContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh) { AssumePrecondition.IsTrue(bh.Count > 0); int Old_bhCount = bh.Count; int Old_bhCapacity = bh.Capacity; int Old_bhMinimumKey = bh.Minimum().Key; int Old_bhMinimumValue = bh.Minimum().Value; //code var rm = bh.RemoveMinimum(); int New_Ret_Key = rm.Key; int New_Ret_Value = rm.Value; int New_bhCount = bh.Count; int New_bhCapacity = bh.Capacity; int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("new_bhMinimumKey"); int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("new_bhMinimumValue"); PexObserve.ValueForViewing("$old_bh_count", Old_bhCount); PexObserve.ValueForViewing("$new_bh_count", New_bhCount); PexObserve.ValueForViewing("$old_bh_capacity", Old_bhCapacity); PexObserve.ValueForViewing("$new_bh_capacity", New_bhCapacity); PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey); PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey); PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue); PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue); PexObserve.ValueForViewing("$new_ret_key", New_Ret_Key); PexObserve.ValueForViewing("$new_ret_value", New_Ret_Value); Assert.IsTrue(false); }
public void PUT_PopContract([PexAssumeUnderTest] Stack.Stack <int> s1) { AssumePrecondition.IsTrue(s1.Count > 0); int Old_s1Count = s1.Count; //int Old_Ret = PexChoose.Value<int>("old_ret"); int Old_Top = s1.Peek(); /*code*/ int New_Ret = s1.Pop(); //Old_ret = New_ret; int New_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("old_top"); //int New_Top = s1.Count > 0 ? s1.Peek() : Old_Top - 1; int New_s1Count = s1.Count; bool New_ContainsNewRet = s1.Contains(New_Ret); PexObserve.ValueForViewing("$Old_s1_Count", Old_s1Count); PexObserve.ValueForViewing("$New_s1_Count", New_s1Count); PexObserve.ValueForViewing("$Old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); //PexObserve.ValueForViewing("$Old_ret", Old_Ret); PexObserve.ValueForViewing("$New_ret", New_Ret); PexObserve.ValueForViewing("$New_ContainsNewRet", New_ContainsNewRet); Assert.True(((New_s1Count == -1 + Old_s1Count && New_Ret == Old_Top))); }
public void PUT_EdgeCountContract([PexAssumeUnderTest] UndirectedGraph.UndirectedGraph <int, Edge <int> > ug) { AssumePrecondition.IsTrue(true); int Old_ugVertexCount = ug.VertexCount; int Old_ugEdgeCount = ug.EdgeCount; int Old_Ret = PexChoose.Value <int>("old_Ret"); bool Old_ugAllowParallelEdges = ug.AllowParallelEdges; //code int New_Ret = ug.EdgeCount; int New_ugVertexCount = ug.VertexCount; int New_ugEdgeCount = ug.EdgeCount; bool New_ugAllowParallelEdges = ug.AllowParallelEdges; PexObserve.ValueForViewing("$old_ug_vertex_count", Old_ugVertexCount); PexObserve.ValueForViewing("$new_ug_vertex_count", New_ugVertexCount); PexObserve.ValueForViewing("$old_ug_edge_count", Old_ugEdgeCount); PexObserve.ValueForViewing("$new_ug_edge_count", New_ugEdgeCount); PexObserve.ValueForViewing("$old_ret", Old_Ret); PexObserve.ValueForViewing("$new_ret", New_Ret); PexObserve.ValueForViewing("$old_ug_allow_parallel_edges", Old_ugAllowParallelEdges); PexObserve.ValueForViewing("$new_ug_allow_parallel_edges", New_ugAllowParallelEdges); PexAssert.IsTrue(false); }
public void PUT_EnqueueContract([PexAssumeUnderTest] Queue.Queue <int> s1, int x) { AssumePrecondition.IsTrue(true); int Old_s1Count = s1.Count; int Old_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("old_top"); //int Old_Top = s1.Count > 0 ? s1.Peek() : x - 1; // OldTop = x; x updates x = x-1 int Old_x = x; bool Old_s1ContainsX = s1.Contains(x); //bool Old_Empty = s1.Count == 0; s1.Enqueue(x); int New_s1Count = s1.Count; int New_Top = s1.Peek(); bool New_s1ContainsX = s1.Contains(x); //bool New_Empty = s1.Count == 0; PexObserve.ValueForViewing("$old_s1_Count", Old_s1Count); PexObserve.ValueForViewing("$new_s1_Count", New_s1Count); PexObserve.ValueForViewing("$old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); PexObserve.ValueForViewing("$old_s1_x", Old_x); PexObserve.ValueForViewing("$old_s1_contains_x", Old_s1ContainsX); PexObserve.ValueForViewing("$new_s1_contains_x", New_s1ContainsX); //PexObserve.ValueForViewing("$Old_NotEmpty", Old_Empty); //PexObserve.ValueForViewing("$New_NotEmpty", New_Empty); Assert.True(((New_s1ContainsX && New_s1Count == 1 + Old_s1Count && (!(Old_s1ContainsX)) && New_s1Count >= 1) || (New_s1ContainsX && New_s1Count == 1 + Old_s1Count && New_Top == Old_Top && New_s1Count >= 2))); }
protected internal override SyntaxTreeNode Visit(TextNode node) { if (!PexChoose.Value <bool>("x")) { return(base.Visit(node)); } return(new TextNode(node.Text, node.HtmlTemplate)); }
protected internal override SyntaxTreeNode Visit(TagNode node) { var baseResult = base.Visit(node); if (!PexChoose.Value <bool>("x")) { return(baseResult); } return(baseResult.SetSubNodes(baseResult.SubNodes.ToList())); }
public void PUT_RemoveEdgeContract([PexAssumeUnderTest] UndirectedGraph.UndirectedGraph <int, Edge <int> > ug, int source, int target) { AssumePrecondition.IsTrue(ug.ContainsVertex(source) && ug.ContainsVertex(target)); int Old_ugVertexCount = ug.VertexCount; int Old_ugEdgeCount = ug.EdgeCount; int Old_ugAdjacentDegreeSource = ug.AdjacentDegree(source); int Old_ugAdjacentDegreeTarget = ug.AdjacentDegree(target); int Old_source = source; int Old_target = target; bool Old_ugAllowParallelEdges = ug.AllowParallelEdges; bool Old_ugContainsVertexSource = ug.ContainsVertex(source); bool Old_ugContainsVertexTarget = ug.ContainsVertex(target); bool Old_Ret = PexChoose.Value <bool>("default_Ret"); //code bool New_Ret = ug.RemoveEdge(new Edge <int>(source, target)); int New_ugVertexCount = ug.VertexCount; int New_ugEdgeCount = ug.EdgeCount; int New_ugAdjacentDegreeSource = ug.AdjacentDegree(source); int New_ugAdjacentDegreeTarget = ug.AdjacentDegree(target); int New_source = source; int New_target = target; bool New_ugAllowParallelEdges = ug.AllowParallelEdges; bool New_ugContainsVertexSource = ug.ContainsVertex(source); bool New_ugContainsVertexTarget = ug.ContainsVertex(target); PexObserve.ValueForViewing("$old_ug_vertex_count", Old_ugVertexCount); PexObserve.ValueForViewing("$new_ug_vertex_count", New_ugVertexCount); PexObserve.ValueForViewing("$old_ug_edge_count", Old_ugEdgeCount); PexObserve.ValueForViewing("$new_ug_edge_count", New_ugEdgeCount); PexObserve.ValueForViewing("$old_ug_adjacent_degree_source", Old_ugAdjacentDegreeSource); PexObserve.ValueForViewing("$new_ug_adjacent_degree_source", New_ugAdjacentDegreeSource); PexObserve.ValueForViewing("$old_ug_adjacent_degree_target", Old_ugAdjacentDegreeTarget); PexObserve.ValueForViewing("$new_ug_adjacent_degree_target", New_ugAdjacentDegreeTarget); PexObserve.ValueForViewing("$old_ug_source", Old_source); PexObserve.ValueForViewing("$new_ug_source", New_source); PexObserve.ValueForViewing("$old_ug_target", Old_target); PexObserve.ValueForViewing("$new_ug_target", New_target); PexObserve.ValueForViewing("$old_ret", Old_Ret); PexObserve.ValueForViewing("$new_ret", New_Ret); PexObserve.ValueForViewing("$old_ug_contains_source", Old_ugContainsVertexSource); PexObserve.ValueForViewing("$new_ug_contains_source", New_ugContainsVertexSource); PexObserve.ValueForViewing("$old_ug_contains_target", Old_ugContainsVertexTarget); PexObserve.ValueForViewing("$new_ug_contains_target", New_ugContainsVertexTarget); PexObserve.ValueForViewing("$old_ug_allow_parallel_edges", Old_ugAllowParallelEdges); PexObserve.ValueForViewing("$new_ug_allow_parallel_edges", New_ugAllowParallelEdges); PexAssert.IsTrue(false); }
public static BinaryHeap <int, int> CreateBinaryHeapPexChoose(int num, int capacity) { PexAssume.IsTrue(num > 0 && num < 20); PexAssume.IsTrue(capacity > 0); var bh = new BinaryHeap <int, int>(capacity, Comparer <int> .Default.Compare); for (int i = 0; i < num; i++) { int priority = PexChoose.Value <int>("priority"); int value = PexChoose.Value <int>("value"); bh.Add(priority, value); } return(bh); }
public void PUT_AdjacentEdgeContract([PexAssumeUnderTest] UndirectedGraph.UndirectedGraph <int, Edge <int> > ug, int x, int index) { AssumePrecondition.IsTrue(ug.ContainsVertex(x) && (index < ug.AdjacentDegree(x)) && (index >= 0)); int Old_ugVertexCount = ug.VertexCount; int Old_ugEdgeCount = ug.EdgeCount; int Old_ugAdjacentDegree = ug.AdjacentDegree(x); int Old_x = x; int Old_index = index; int Old_Ret_Source = PexChoose.Value <int>("old_Ret_Source"); int Old_Ret_Target = PexChoose.Value <int>("old_Ret_Target"); bool Old_ugAllowParallelEdges = ug.AllowParallelEdges; bool Old_ugContainsVertexX = ug.ContainsVertex(x); //code var e = ug.AdjacentEdge(x, index); int New_Ret_Source = e.Source; int New_Ret_Target = e.Target; int New_ugVertexCount = ug.VertexCount; int New_ugEdgeCount = ug.EdgeCount; int New_ugAdjacentDegree = ug.AdjacentDegree(x); int New_x = x; int New_index = index; bool New_ugAllowParallelEdges = ug.AllowParallelEdges; bool New_ugContainsVertexX = ug.ContainsVertex(x); PexObserve.ValueForViewing("$old_ug_vertex_count", Old_ugVertexCount); PexObserve.ValueForViewing("$new_ug_vertex_count", New_ugVertexCount); PexObserve.ValueForViewing("$old_ug_edge_count", Old_ugEdgeCount); PexObserve.ValueForViewing("$new_ug_edge_count", New_ugEdgeCount); PexObserve.ValueForViewing("$old_ug_adjacent_degree", Old_ugAdjacentDegree); PexObserve.ValueForViewing("$new_ug_adjacent_degree", New_ugAdjacentDegree); PexObserve.ValueForViewing("$old_ug_x", Old_x); PexObserve.ValueForViewing("$new_ug_x", New_x); PexObserve.ValueForViewing("$old_ug_index", Old_index); PexObserve.ValueForViewing("$new_ug_index", New_index); PexObserve.ValueForViewing("$old_ret_source", Old_Ret_Source); PexObserve.ValueForViewing("$new_ret_source", New_Ret_Source); PexObserve.ValueForViewing("$old_ret_target", Old_Ret_Target); PexObserve.ValueForViewing("$new_ret_target", New_Ret_Target); PexObserve.ValueForViewing("$old_ug_contains_x", Old_ugContainsVertexX); PexObserve.ValueForViewing("$new_ug_contains_x", New_ugContainsVertexX); PexObserve.ValueForViewing("$old_ug_allow_parallel_edges", Old_ugAllowParallelEdges); PexObserve.ValueForViewing("$new_ug_allow_parallel_edges", New_ugAllowParallelEdges); PexAssert.IsTrue(false); }
public void PUT_UpdateContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int priority, int value) { //ahmad alternate semantics AssumePrecondition.IsTrue(true); int Old_bhCount = bh.Count; int Old_bhIndexOfValue = bh.IndexOf(value); int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("old_bhMinimumKey"); //int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : priority -1; int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("old_bhMinimumValue"); //int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : value -1; //int Old_bhMinimumKey = bh.Minimum().Key ; //int Old_bhMinimumValue = bh.Minimum().Value; int Old_priority = priority; int Old_value = value; //code bh.Update(priority, value); int New_bhCount = bh.Count; int New_bhIndexOfValue = bh.IndexOf(value); //int New_bhMinimumKey = bh.Minimum().Key; int New_bhMinimumKey = bh.Minimum().Key; //int New_bhMinimumValue = bh.Minimum().Value; int New_bhMinimumValue = bh.Minimum().Value; //int New_prioirty = priority; //int New_value = value; PexObserve.ValueForViewing("$old_bh_count", Old_bhCount); PexObserve.ValueForViewing("$new_bh_count", New_bhCount); PexObserve.ValueForViewing("$old_bh_indexof_value", Old_bhIndexOfValue); PexObserve.ValueForViewing("$new_bh_indexof_value", New_bhIndexOfValue); PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey); PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey); PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue); PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue); PexObserve.ValueForViewing("$old_bh_priority", Old_priority); //PexObserve.ValueForViewing("$new_bh_priority", New_prioirty); PexObserve.ValueForViewing("$old_bh_value", Old_value); //PexObserve.ValueForViewing("$new_bh_value", New_value); Assert.True(((Old_bhCount <= New_bhCount && New_bhMinimumKey <= Old_priority && (!(New_bhIndexOfValue == New_bhCount)) && (!(Old_bhIndexOfValue == Old_bhCount)) && Old_bhIndexOfValue <= Old_bhCount && New_bhIndexOfValue <= Old_bhCount && New_bhIndexOfValue >= 0 && Old_bhIndexOfValue >= -1))); }
public int ProcessOperations(int startBalance) { int balance = startBalance; int withdrawalsCount = 0; while (PexChoose.Value <bool>("operationLoop")) { bool operation = PexChoose.Value <bool>("operationType"); int amount = PexChoose.Value <int>("amount"); if (operation) { // Deposit if (amount > 0) { balance = balance + amount; } else { Evaluation.InvalidUnreachable(); } } else { // Withdraw if (amount > balance) { Evaluation.InvalidUnreachable(); } else if (withdrawalsCount >= 10) { Evaluation.InvalidUnreachable(); } else { balance = balance - amount; withdrawalsCount = withdrawalsCount + 1; } } } return(balance); }
public void PUT_UpdateContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int priority, int value) { AssumePrecondition.IsTrue(bh.IndexOf(value) >= 0); int Old_bhCount = bh.Count; int Old_bhCapacity = bh.Capacity; int Old_bhIndexOfValue = bh.IndexOf(value); //int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value<int>("old_bhMinimumKey"); //int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value<int>("old_bhMinimumValue"); int Old_bhMinimumKey = bh.Minimum().Key; int Old_bhMinimumValue = bh.Minimum().Value; int Old_prioirty = priority; int Old_value = value; //code bh.Update(priority, value); int New_bhCount = bh.Count; int New_bhCapacity = bh.Capacity; int Newd_bhIndexOfValue = bh.IndexOf(value); int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("new_bhMinimumKey"); int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("new_bhMinimumValue"); int New_prioirty = priority; int New_value = value; PexObserve.ValueForViewing("$old_bh_count", Old_bhCount); PexObserve.ValueForViewing("$new_bh_count", New_bhCount); PexObserve.ValueForViewing("$old_bh_capacity", Old_bhCapacity); PexObserve.ValueForViewing("$new_bh_capacity", New_bhCapacity); PexObserve.ValueForViewing("$old_bh_indexof_value", Old_bhIndexOfValue); PexObserve.ValueForViewing("$new_bh_indexof_value", Newd_bhIndexOfValue); PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey); PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey); PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue); PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue); PexObserve.ValueForViewing("$old_bh_priority", Old_prioirty); PexObserve.ValueForViewing("$new_bh_priority", New_prioirty); PexObserve.ValueForViewing("$old_bh_value", Old_value); PexObserve.ValueForViewing("$new_bh_value", New_value); Assert.IsTrue(false); }
public void Push(int x) { int oldX = x; int oldTop = _top; int oldCount = _count; bool oldContainsX = _containsX; PexAssert.IsTrue(true); _top = PexChoose.Value <int>("_topPush"); _count = PexChoose.Value <int>("_countPush"); _containsX = PexChoose.Value <bool>("_containsXPush"); Debug.WriteLine("_top is: " + _top); Debug.WriteLine("_count is: " + _count); Debug.WriteLine("_count is: " + _containsX); PexAssume.IsTrue((_containsX == true) && (_top == x) && (_count == oldCount + 1) && (oldX == x)); //(New_s1ContainsX) && (New_Top == Old_x) && (New_s1Count == 1 + Old_s1Count) && (New_Top == New_x) }
public int Pop() { int oldTop = _top; int oldCount = _count; bool oldContainsX = _containsX; int ret = 0; PexAssert.IsTrue(_count > 0); _top = PexChoose.Value <int>("_topPop"); _count = PexChoose.Value <int>("_countPop"); _containsX = PexChoose.Value <bool>("_containsXPop"); ret = PexChoose.Value <int>("_retPop"); PexAssume.IsTrue((_count == oldCount - 1) && (ret == oldTop)); return(ret); }
public void PUT_RemoveAtContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int index) { AssumePrecondition.IsTrue(index < bh.Count && index >= 0); int Old_bhCount = bh.Count; int Old_bhCapacity = bh.Capacity; int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("old_bhMinimumKey"); int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("old_bhMinimumValue"); int Old_index = index; int Old_Ret_Key = PexChoose.Value <int>("old_Ret_Key"); int Old_Ret_Value = PexChoose.Value <int>("old_Ret_Value"); //code var ra = bh.RemoveAt(index); int New_Ret_Key = ra.Key; int New_Ret_Value = ra.Value; int New_bhCount = bh.Count; int New_bhCapacity = bh.Capacity; int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("new_bhMinimumKey"); int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("new_bhMinimumValue"); int New_index = index; PexObserve.ValueForViewing("$old_bh_count", Old_bhCount); PexObserve.ValueForViewing("$new_bh_count", New_bhCount); PexObserve.ValueForViewing("$old_bh_capacity", Old_bhCapacity); PexObserve.ValueForViewing("$new_bh_capacity", New_bhCapacity); PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey); PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey); PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue); PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue); PexObserve.ValueForViewing("$old_bh_index", Old_index); PexObserve.ValueForViewing("$new_bh_index", New_index); PexObserve.ValueForViewing("$old_ret_key", Old_Ret_Key); PexObserve.ValueForViewing("$new_ret_key", New_Ret_Key); PexObserve.ValueForViewing("$old_ret_value", Old_Ret_Value); PexObserve.ValueForViewing("$new_ret_value", New_Ret_Value); PexAssert.IsTrue(false); }
public void PUT_IsAdjacentEdgesEmptyContract([PexAssumeUnderTest] UndirectedGraph.UndirectedGraph <int, Edge <int> > ug, int x) { AssumePrecondition.IsTrue(ug.ContainsVertex(x)); int Old_ugVertexCount = ug.VertexCount; int Old_ugEdgeCount = ug.EdgeCount; int Old_ugAdjacentDegree = ug.AdjacentDegree(x); int Old_x = x; bool Old_ugAllowParallelEdges = ug.AllowParallelEdges; bool Old_ugContainsVertexX = ug.ContainsVertex(x); bool Old_Ret = PexChoose.Value <bool>("default_Ret"); //code bool New_Ret = ug.IsAdjacentEdgesEmpty(x); int New_ugVertexCount = ug.VertexCount; int New_ugEdgeCount = ug.EdgeCount; int New_ugAdjacentDegree = ug.AdjacentDegree(x); int New_x = x; bool New_ugAllowParallelEdges = ug.AllowParallelEdges; bool New_ugContainsVertexX = ug.ContainsVertex(x); PexObserve.ValueForViewing("$old_ug_vertex_count", Old_ugVertexCount); PexObserve.ValueForViewing("$new_ug_vertex_count", New_ugVertexCount); PexObserve.ValueForViewing("$old_ug_edge_count", Old_ugEdgeCount); PexObserve.ValueForViewing("$new_ug_edge_count", New_ugEdgeCount); PexObserve.ValueForViewing("$old_ug_adjacent_degree", Old_ugAdjacentDegree); PexObserve.ValueForViewing("$new_ug_adjacent_degree", New_ugAdjacentDegree); PexObserve.ValueForViewing("$old_ug_x", Old_x); PexObserve.ValueForViewing("$new_ug_x", New_x); PexObserve.ValueForViewing("$old_ret", Old_Ret); PexObserve.ValueForViewing("$new_ret", New_Ret); PexObserve.ValueForViewing("$old_ug_contains_x", Old_ugContainsVertexX); PexObserve.ValueForViewing("$new_ug_contains_x", New_ugContainsVertexX); PexObserve.ValueForViewing("$old_ug_allow_parallel_edges", Old_ugAllowParallelEdges); PexObserve.ValueForViewing("$new_ug_allow_parallel_edges", New_ugAllowParallelEdges); PexAssert.IsTrue(false); }
public void PUT_AddContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int key, int value) { AssumePrecondition.IsTrue(true); int Old_bhCount = bh.Count; //int Old_bhCapacity = bh.Capacity; int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value <int>("old_bhMinimumKey"); int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("old_bhMinimumValue"); //int Old_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : key + 1; //PexChoose.Value<int>("old_bhMinimumKey"); //int Old_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : value + 1; //PexChoose.Value<int>("old_bhMinimumValue"); int Old_bhIndexOfValue = bh.IndexOf(value); int Old_key = key; int Old_value = value; //code bh.Add(key, value); int New_bhCount = bh.Count; //int New_bhCapacity = bh.Capacity; int New_bhMinimumKey = bh.Minimum().Key; // bh.Count > 0 ? bh.Minimum().Key : PexChoose.Value<int>("new_bhMinimumKey"); int New_bhMinimumValue = bh.Minimum().Value; //bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value<int>("new_bhMinimumValue"); int New_bhIndexOfValue = bh.IndexOf(value); PexObserve.ValueForViewing("$old_bh_count", Old_bhCount); PexObserve.ValueForViewing("$new_bh_count", New_bhCount); PexObserve.ValueForViewing("$old_bh_key", Old_key); PexObserve.ValueForViewing("$old_bh_value", Old_value); //PexObserve.ValueForViewing("$old_bh_capacity", Old_bhCapacity); //PexObserve.ValueForViewing("$new_bh_capacity", New_bhCapacity); PexObserve.ValueForViewing("$old_bh_indexof_value", Old_bhIndexOfValue); PexObserve.ValueForViewing("$new_bh_indexof_value", New_bhIndexOfValue); PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey); PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey); PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue); PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue); Assert.True(((New_bhMinimumKey <= Old_key && New_bhCount == 1 + Old_bhCount && (!(Old_bhIndexOfValue == Old_bhCount)) && Old_bhIndexOfValue <= Old_bhCount && New_bhIndexOfValue <= Old_bhCount && New_bhIndexOfValue >= 0 && Old_bhIndexOfValue >= -1))); }
public void PUT_CountContract([PexAssumeUnderTest] Stack.Stack <int> s1) { AssumePrecondition.IsTrue(true); //int Old_Ret = PexChoose.Value<int>("old_ret"); int Old_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("old_top"); /*Code */ int New_Ret = s1.Count; int New_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("new_top"); //int New_Top = Old_Top; // consult about this decision later //bool New_ContainsNewRet = s1.Contains(New_Ret); PexObserve.ValueForViewing("$old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); //PexObserve.ValueForViewing("$old_s1_ret", Old_Ret); PexObserve.ValueForViewing("$new_ret", New_Ret); //PexObserve.ValueForViewing("$New_ContainsNewRet", New_ContainsNewRet); Assert.True(((Old_Top <= New_Ret && New_Ret >= 0) || (New_Top == Old_Top && New_Ret >= 0 && Old_Top >= 1) || (New_Top == Old_Top && New_Ret == 0) || (New_Ret == 0 && New_Top >= 1) || (New_Top <= Old_Top && New_Ret == 0) || (New_Top <= Old_Top && New_Top <= 0 && New_Ret == 0))); }
public void PUT_CountContract([PexAssumeUnderTest] Queue.Queue <int> s1) { AssumePrecondition.IsTrue(true); int Old_s1Count = s1.Count; //int Old_Ret = PexChoose.Value<int>("old_ret"); int Old_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("old_top"); /*Code */ int New_Ret = s1.Count; int New_s1Count = s1.Count; int New_Top = Old_Top; // consult about this decision later PexObserve.ValueForViewing("$old_s1_Count", Old_s1Count); PexObserve.ValueForViewing("$new_s1_Count", New_s1Count); PexObserve.ValueForViewing("$old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); //PexObserve.ValueForViewing("$old_s1_ret", Old_Ret); PexObserve.ValueForViewing("$new_ret", New_Ret); Assert.True(((New_Top == Old_Top && New_Ret == Old_s1Count && New_Ret == New_s1Count))); }
public void PUT_RemoveAtContract([PexAssumeUnderTest] BinaryHeap.BinaryHeap <int, int> bh, int index) { AssumePrecondition.IsTrue(index < bh.Count && index >= 0); int Old_bhCount = bh.Count; int Old_bhMinimumKey = bh.Minimum().Key; int Old_bhMinimumValue = bh.Minimum().Value; int Old_index = index; //bool Old_removeAtRoot = index == 0; //code var ra = bh.RemoveAt(index); int New_Ret_Key = ra.Key; int New_Ret_Value = ra.Value; int New_bhCount = bh.Count; int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key: PexChoose.Value <int>("new_min_key"); //int New_bhMinimumKey = bh.Count > 0 ? bh.Minimum().Key : Old_bhMinimumKey-1; int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : PexChoose.Value <int>("new_min_val"); //int New_bhMinimumValue = bh.Count > 0 ? bh.Minimum().Value : Old_bhMinimumValue - 1; PexObserve.ValueForViewing("$old_bh_count", Old_bhCount); PexObserve.ValueForViewing("$new_bh_count", New_bhCount); PexObserve.ValueForViewing("$old_bh_minimum_key", Old_bhMinimumKey); PexObserve.ValueForViewing("$new_bh_minimum_key", New_bhMinimumKey); PexObserve.ValueForViewing("$old_bh_minimum_value", Old_bhMinimumValue); PexObserve.ValueForViewing("$new_bh_minimum_value", New_bhMinimumValue); PexObserve.ValueForViewing("$old_bh_index", Old_index); PexObserve.ValueForViewing("$new_ret_key", New_Ret_Key); PexObserve.ValueForViewing("$new_ret_value", New_Ret_Value); Assert.True(((Old_index <= New_bhCount && New_bhCount == -1 + Old_bhCount && Old_bhMinimumKey <= New_Ret_Key && Old_index >= 0))); }
static SyntaxTreeNode CreateNode(BBTag[] allowedTags, bool allowText) { switch (PexChoose.ValueFromRange("type", allowText ? 0 : 1, 2)) { case 0: var text = PexChoose.Value <string>("text"); PexAssume.IsTrue(!String.IsNullOrEmpty(text)); return(new TextNode(text)); case 1: var tag = allowedTags[PexChoose.ValueFromRange("tag", 0, allowedTags.Length)]; var node = new TagNode(tag); AddSubnodes(allowedTags, node); if (tag.Attributes != null) { var selectedIds = new List <string>(); foreach (var attr in tag.Attributes) { if (!selectedIds.Contains(attr.ID) && PexChoose.Value <bool>("include")) { var val = PexChoose.Value <string>("val"); PexAssume.IsTrue(val != null); PexAssume.IsTrue(val.IndexOfAny("[] ".ToCharArray()) == -1); node.AttributeValues[attr] = val; selectedIds.Add(attr.ID); } } } return(node); default: PexAssume.Fail(); return(null); } }
public void PUT_CountContract([PexAssumeUnderTest] Queue.Queue <int> s1) { AssumePrecondition.IsTrue(true); //int Old_s1Count = s1.Count; int Old_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("old_top"); /*Code */ int New_Ret = s1.Count; //int New_s1Count = s1.Count; int New_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("new_top"); //int New_Top = Old_Top; // alternate semantics //bool New_ContainsNewRet = s1.Contains(New_Ret); //PexObserve.ValueForViewing("$old_s1_Count", Old_s1Count); //PexObserve.ValueForViewing("$new_s1_Count", New_s1Count); PexObserve.ValueForViewing("$old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); PexObserve.ValueForViewing("$new_ret", New_Ret); //PexObserve.ValueForViewing("$new_containsNewRet", New_ContainsNewRet); Assert.True(((New_Top == Old_Top && New_Ret >= 0) || New_Ret == 0)); }
public string FooTest( [PexAssumeUnderTest] Bar target, Foo iksDee, bool b, bool c ) { PexAssume.IsNotNull(iksDee); string result = target.Foo(iksDee, b, c); PexAssume.IsNotNull(target); int i = PexChoose.Value <int>("i"); PexObserve.ValueForViewing <int>("yo_add_this_thing", i); PexObserve.Value <string>("Hello, World!", "Foo"); string helloWorld = PexChoose.Value <string>("Hello, World!"); Console.WriteLine(helloWorld); return(result); // TODO: add assertions to method BarTest.FooTest(Bar, Foo, Boolean, Boolean) }
public void PUT_DequeueContract([PexAssumeUnderTest] Queue.Queue <int> s1) { AssumePrecondition.IsTrue(s1.Count > 0); int Old_s1Count = s1.Count; int Old_Top = s1.Peek(); /*code*/ int New_Ret = s1.Dequeue(); int New_Top = s1.Count > 0 ? s1.Peek() : PexChoose.Value <int>("new_top"); //int New_Top = s1.Count > 0 ? s1.Peek() : Old_Top - 1; // New_Top = Old_Top = OldTop - 1 int New_s1Count = s1.Count; bool New_s1ContainsNewRet = s1.Contains(New_Ret); PexObserve.ValueForViewing("$Old_s1_Count", Old_s1Count); PexObserve.ValueForViewing("$New_s1_Count", New_s1Count); PexObserve.ValueForViewing("$Old_s1_Peek", Old_Top); PexObserve.ValueForViewing("$new_s1_Peek", New_Top); PexObserve.ValueForViewing("$New_ret", New_Ret); PexObserve.ValueForViewing("$New_s1ContainsNewRet", New_s1ContainsNewRet); Assert.True(((New_s1Count == -1 + Old_s1Count && New_Ret <= Old_Top && Old_Top <= New_Ret && (!(New_s1ContainsNewRet)) && New_s1Count >= 0) || (New_s1Count == -1 + Old_s1Count && New_Ret <= Old_Top && Old_Top <= New_Ret && New_s1Count >= 1))); }