Esempio n. 1
0
        public void GlobalConstantWithWeakerAxiom()
        {
            p = LoadProgramFrom("programs/GlobalConstantWithWeakerAxiom.bpl");
            e = GetExecutor(p);
            e.BreakPointReached += delegate(object executor, Executor.BreakPointEventArgs data)
            {
                Assert.IsTrue(data.Name == "entry");
                var constant = p.TopLevelDeclarations.OfType <Constant>().Where(c => c.Name == "a").First();
                Assert.IsTrue(constant is Constant);
                Assert.IsTrue(e.CurrentState.IsInScopeVariable(constant));
                Assert.IsTrue(e.IsSymbolic(constant));

                // Check for the expected constraint
                bool found = false;
                foreach (Expr constraint in e.CurrentState.Constraints.ConstraintExprs)
                {
                    var asNeq = ExprUtil.AsNotEq(constraint);
                    if (asNeq != null)
                    {
                        var asSymVar = ExprUtil.AsSymbolicVariable(asNeq.Args[0]);
                        Assert.IsNotNull(asSymVar);
                        Assert.IsTrue(asSymVar.Origin.IsVariable && asSymVar.Origin.AsVariable == constant);
                        Assert.IsTrue(asNeq.Args[1] is LiteralExpr && (asNeq.Args[1] as LiteralExpr).asBvConst.Value.ToInt == 7);
                        found = true;
                    }
                }
                Assert.IsTrue(found, "Did not find expected Neq constraint");
            };
            e.Run(GetMain(p));
        }
Esempio n. 2
0
        public void AsNotEqWithoutNotEq()
        {
            var sb      = GetSimpleBuilder();
            var v       = GetVarAndIdExpr("foo", BasicType.GetBvType(4)).Item2;
            var e       = sb.Eq(v, sb.ConstantBV(0, 4));
            var asNotEq = ExprUtil.AsNotEq(e);

            Assert.IsNull(asNotEq);
        }
Esempio n. 3
0
        public void notEq()
        {
            var cfb      = GetConstantFoldingBuilder();
            var x        = GetVarAndIdExpr("x", Microsoft.Boogie.Type.Int).Item2;
            var rhsConst = cfb.ConstantInt(0);
            var e        = cfb.Not(cfb.Eq(x, rhsConst));
            var asNotEq  = ExprUtil.AsNotEq(e);

            Assert.IsNotNull(asNotEq);
            Assert.AreSame(rhsConst, asNotEq.Args[0]);
            Assert.AreSame(x, asNotEq.Args[1]);
        }
Esempio n. 4
0
        public void MergeNotEqToNotCondition()
        {
            var builder   = GetConstantFoldingBuilder();
            var v         = GetVarAndIdExpr("group_size_y", BasicType.GetBvType(32)).Item2;
            var condition = builder.Eq(v, builder.ConstantBV(1, 32));
            var ite       = builder.IfThenElse(condition, builder.ConstantBV(0, 1), builder.ConstantBV(1, 1));

            Assert.IsNull(ExprUtil.AsLiteral(ite));
            var result = builder.NotEq(ite, builder.ConstantBV(0, 1));

            CheckIsBoolType(result);
            var expected = builder.NotEq(v, builder.ConstantBV(1, 32));

            Assert.IsNotNull(ExprUtil.AsNotEq(result));
            Assert.IsTrue(expected.Equals(result));
        }