Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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()));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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()));
        }