public void EnumeratorClone() { p = LoadProgramFrom("programs/Concretise.bpl"); var block = GetMain(p).Blocks[0]; var blockEnumerator = new BlockCmdEnumerator(block); Assert.AreEqual(5, blockEnumerator.Count); blockEnumerator.MoveNext(); blockEnumerator.MoveNext(); var copiedblockEnumerator = blockEnumerator.Clone(); var oldPosition = blockEnumerator.Current; blockEnumerator.MoveNext(); // The copied blockEnumerator shouldn't have moved. Assert.AreSame(oldPosition, copiedblockEnumerator.Current); copiedblockEnumerator.MoveNext(); Assert.AreSame(blockEnumerator.Current, copiedblockEnumerator.Current); oldPosition = copiedblockEnumerator.Current; copiedblockEnumerator.MoveNext(); // The blockEnumerator shouldn't have moved. Assert.AreSame(oldPosition, blockEnumerator.Current); }
public void EntryWithImmediateGoto() { p = LoadProgramFrom("programs/EntryWithImmediateGoto.bpl"); var block = GetMain(p).Blocks[0]; var blockEnumerator = new BlockCmdEnumerator(block); Assert.AreEqual(1, blockEnumerator.Count); blockEnumerator.MoveNext(); Assert.AreEqual("goto end;", TrimNewLines(blockEnumerator.Current.ToString())); }
public void EnumeratorHitEnd() { p = LoadProgramFrom("programs/GotoMultiplePaths.bpl"); var block = GetMain(p).Blocks[0]; var blockEnumerator = new BlockCmdEnumerator(block); Assert.AreEqual(2, blockEnumerator.Count); bool ok = blockEnumerator.MoveNext(); Assert.IsTrue(ok); Assert.AreSame(block.Cmds[0], blockEnumerator.Current); ok = blockEnumerator.MoveNext(); Assert.IsTrue(ok); Assert.AreSame(block.TransferCmd, blockEnumerator.Current); ok = blockEnumerator.MoveNext(); Assert.IsFalse(ok); }
public void EnumeratorMovePastEnd() { p = LoadProgramFrom("programs/GotoMultiplePaths.bpl"); var block = GetMain(p).Blocks[0]; var blockEnumerator = new BlockCmdEnumerator(block); Assert.AreEqual(2, blockEnumerator.Count); bool ok = false; for (int i = 0; i < 2; ++i) { ok = blockEnumerator.MoveNext(); Assert.IsTrue(ok); } ok = blockEnumerator.MoveNext(); Assert.IsFalse(ok); // Should throw InvalidOperation var x = blockEnumerator.Current; }
public void EnumeratorMultipleCmds() { p = LoadProgramFrom("programs/Concretise.bpl"); var block = GetMain(p).Blocks[0]; var blockEnumerator = new BlockCmdEnumerator(block); Assert.AreEqual(5, blockEnumerator.Count); blockEnumerator.MoveNext(); Assert.AreEqual("assert {:symbooglix_bp \"entry\"} true;", TrimNewLines(blockEnumerator.Current.ToString())); blockEnumerator.MoveNext(); Assert.AreEqual("a := 1bv8;", TrimNewLines(blockEnumerator.Current.ToString())); blockEnumerator.MoveNext(); Assert.AreEqual("x := 2bv8;", TrimNewLines(blockEnumerator.Current.ToString())); blockEnumerator.MoveNext(); Assert.AreEqual("assert {:symbooglix_bp \"now_concrete\"} true;", TrimNewLines(blockEnumerator.Current.ToString())); blockEnumerator.MoveNext(); Assert.AreEqual("return;", TrimNewLines(blockEnumerator.Current.ToString())); }