public void Empty() { var stack = new StackState <DummyValue>(); Assert.Equal(0, stack.Size); Assert.Null(stack.Top); Assert.Empty(stack.GetAllStackSlots()); }
public void PushManyReversed() { var stack = new StackState <DummyValue>(); var values = CreateDummyValues(3); stack.Push(values, reversed: true); Assert.Equal(3, stack.Size); Assert.Equal(values.First(), stack.Top); Assert.Equal(values, stack.GetAllStackSlots()); }
public void Push() { var stack = new StackState <DummyValue>(); var value = new DummyValue(); stack.Push(value); Assert.Equal(1, stack.Size); Assert.Equal(value, stack.Top); Assert.Single(stack.GetAllStackSlots()); }
public void Copy() { var stack = new StackState <DummyValue>(); stack.Push(CreateDummyValues(3)); var copy = stack.Copy(); Assert.Equal(stack.Top, copy.Top); Assert.Equal(stack.Size, copy.Size); Assert.Equal(stack.GetAllStackSlots(), copy.GetAllStackSlots()); }
public void MergeMultiple() { var sources = new[] { new[] { CreateDummyNode(0), CreateDummyNode(1) }, new[] { CreateDummyNode(2), CreateDummyNode(3), }, new[] { CreateDummyNode(4), CreateDummyNode(5), } }; var stack1 = new StackState <SymbolicValue <DummyInstruction> >(); var values1 = new[] { new SymbolicValue <DummyInstruction>(sources[0][0]), new SymbolicValue <DummyInstruction>(sources[1][0]), new SymbolicValue <DummyInstruction>(sources[2][0]), }; stack1.Push(values1); var stack2 = new StackState <SymbolicValue <DummyInstruction> >(); var values2 = new[] { new SymbolicValue <DummyInstruction>(sources[0][1]), new SymbolicValue <DummyInstruction>(sources[1][1]), new SymbolicValue <DummyInstruction>(sources[2][1]), }; stack2.Push(values2); Assert.True(stack1.MergeWith(stack2)); int index = sources.Length - 1; foreach (var slot in stack1.GetAllStackSlots()) { Assert.Equal(new HashSet <DataFlowNode <DummyInstruction> >(sources[index]), slot.GetNodes()); index--; } }