Esempio n. 1
0
        public void nestedNegs(int depth)
        {
            var  pair     = GetVarAndIdExpr("foo", BasicType.Int);
            var  variable = pair.Item1;
            var  id       = pair.Item2;
            var  cfb      = GetConstantFoldingBuilder();
            Expr result   = id;

            for (int i = 0; i < depth; ++i)
            {
                result = cfb.Neg(result);
                CheckIsInt(result);
            }

            if (depth % 2 == 0)
            {
                Assert.AreSame(id, result);
            }
            else
            {
                var asNeg = ExprUtil.AsNeg(result);
                Assert.IsNotNull(asNeg);
                Assert.AreSame(id, asNeg.Args[0]);
            }
        }
Esempio n. 2
0
        public void LhsRealZero()
        {
            var cfb    = GetConstantFoldingBuilder();
            var x      = GetVarAndIdExpr("x", BasicType.Real).Item2;
            var result = cfb.Sub(cfb.ConstantReal("0.0"), x);

            CheckIsReal(result);
            var asNeg = ExprUtil.AsNeg(result);

            Assert.IsNotNull(asNeg);
            Assert.AreSame(x, asNeg.Args[0]);
        }
Esempio n. 3
0
        public void noFold()
        {
            var pair         = GetSimpleAndConstantFoldingBuilder();
            var sb           = pair.Item1;
            var cfb          = pair.Item2;
            var id           = GetVarAndIdExpr("foo", BasicType.Int).Item2;
            var foldedResult = cfb.Neg(id);
            var simpleResult = sb.Neg(id);

            CheckIsInt(foldedResult);
            CheckIsInt(simpleResult);
            Assert.AreEqual(simpleResult, foldedResult);

            var asNeg = ExprUtil.AsNeg(foldedResult);

            Assert.IsNotNull(asNeg);
            Assert.AreSame(id, asNeg.Args[0]);
        }