Esempio n. 1
0
 public void DomDiamondTest()
 {
     Procedure proc = new DiamondMock().Procedure;
     BlockDominatorGraph doms = proc.CreateBlockDominatorGraph();
     var topDiamond = proc.ControlGraph.Blocks[2];
     Assert.IsTrue(doms.DominatesStrictly(topDiamond, topDiamond.ElseBlock));
     Assert.IsTrue(doms.DominatesStrictly(topDiamond, topDiamond.ThenBlock));
     Assert.IsTrue(doms.DominatesStrictly(topDiamond, topDiamond.ThenBlock.Succ[0]));
 }
Esempio n. 2
0
        public void DomDiamondTest()
        {
            Procedure           proc = new DiamondMock().Procedure;
            BlockDominatorGraph doms = proc.CreateBlockDominatorGraph();
            var topDiamond           = proc.ControlGraph.Blocks[2];

            Assert.IsTrue(doms.DominatesStrictly(topDiamond, topDiamond.ElseBlock));
            Assert.IsTrue(doms.DominatesStrictly(topDiamond, topDiamond.ThenBlock));
            Assert.IsTrue(doms.DominatesStrictly(topDiamond, topDiamond.ThenBlock.Succ[0]));
        }
Esempio n. 3
0
        public void DomStmDominators()
        {
            Procedure proc = new DiamondMock().Procedure;
            var doms = proc.CreateBlockDominatorGraph();
            Block head = proc.EntryBlock.Succ[0];
            Block f = head.ElseBlock;
            Block t = head.ThenBlock;
            Block join = t.Succ[0];

            Assert.IsTrue(doms.DominatesStrictly(join.Statements[0], join.Statements[1]), "First statement should dominate next statement");
            Assert.IsFalse(doms.DominatesStrictly(join.Statements[1], join.Statements[0]), "Second statement shouldn't  dominate prev statement");
            Assert.IsFalse(doms.DominatesStrictly(join.Statements[1], join.Statements[1]), "Statement doesn't dominate self");
            Assert.IsTrue(doms.DominatesStrictly(head.Statements[0], join.Statements[0]), "head dominates join!");
        }
Esempio n. 4
0
        public void DomStmDominators()
        {
            Procedure proc = new DiamondMock().Procedure;
            var       doms = proc.CreateBlockDominatorGraph();
            Block     head = proc.EntryBlock.Succ[0];
            Block     f    = head.ElseBlock;
            Block     t    = head.ThenBlock;
            Block     join = t.Succ[0];

            Assert.IsTrue(doms.DominatesStrictly(join.Statements[0], join.Statements[1]), "First statement should dominate next statement");
            Assert.IsFalse(doms.DominatesStrictly(join.Statements[1], join.Statements[0]), "Second statement shouldn't  dominate prev statement");
            Assert.IsFalse(doms.DominatesStrictly(join.Statements[1], join.Statements[1]), "Statement doesn't dominate self");
            Assert.IsTrue(doms.DominatesStrictly(head.Statements[0], join.Statements[0]), "head dominates join!");
        }
Esempio n. 5
0
 public void DomDominatorCommon()
 {
     Procedure proc = new DiamondMock().Procedure;
     var doms = proc.CreateBlockDominatorGraph();
     Block head = proc.EntryBlock.Succ[0];
     Block f = head.ElseBlock;
     Block t = head.ThenBlock;
     Block join = t.Succ[0];
     Assert.AreEqual("false", f.Name);
     Assert.AreEqual("true", t.Name);
     Assert.AreEqual("join", join.Name);
     Assert.IsNull(doms.CommonDominator(null), "Common denominator of no items is null");
     Assert.AreSame(head, doms.CommonDominator(new Block[] { head }), "Common dominator of single item is that item");
     Assert.AreSame(head, doms.CommonDominator(new Block[] { head, t }), "head dom true");
     Assert.AreSame(head, doms.CommonDominator(new Block[] { t, head }), "head dom true");
     Assert.AreSame(head, doms.CommonDominator(new Block[] { head, f}), "head dom true");
     Assert.AreSame(head, doms.CommonDominator(new Block[] { f, head }), "head dom true");
     Assert.AreSame(head, doms.CommonDominator(new Block[] { f, t }), "head dom true");
 }
Esempio n. 6
0
        public void DomDominatorCommon()
        {
            Procedure proc = new DiamondMock().Procedure;
            var       doms = proc.CreateBlockDominatorGraph();
            Block     head = proc.EntryBlock.Succ[0];
            Block     f    = head.ElseBlock;
            Block     t    = head.ThenBlock;
            Block     join = t.Succ[0];

            Assert.AreEqual("false", f.DisplayName);
            Assert.AreEqual("true", t.DisplayName);
            Assert.AreEqual("join", join.DisplayName);
            Assert.IsNull(doms.CommonDominator(null), "Common denominator of no items is null");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { head }), "Common dominator of single item is that item");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { head, t }), "head dom true");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { t, head }), "head dom true");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { head, f }), "head dom true");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { f, head }), "head dom true");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { f, t }), "head dom true");
        }