Exemplo n.º 1
0
        public void DivideByZero()
        {
            var builderPair = GetSimpleAndConstantFoldingBuilder();
            var cfb         = builderPair.Item2;
            var result      = cfb.Div(cfb.ConstantInt(8), cfb.ConstantInt(0));

            CheckIsInt(result);
            Assert.IsNull(ExprUtil.AsLiteral(result));
            Assert.IsNotNull(ExprUtil.AsDiv(result));
            Assert.AreEqual("8 div 0", result.ToString());
        }
Exemplo n.º 2
0
        public void ZeroDivideByIntExpr()
        {
            var builderPair = GetSimpleAndConstantFoldingBuilder();
            var x           = GetVarAndIdExpr("x", BasicType.Int).Item2;
            var cfb         = builderPair.Item2;
            var result      = cfb.Div(cfb.ConstantInt(0), x);

            CheckIsInt(result);
            Assert.IsFalse(ExprUtil.IsZero(result));
            Assert.IsNotNull(ExprUtil.AsDiv(result));
        }
Exemplo n.º 3
0
        public void NestedDivInt()
        {
            var builderPair = GetSimpleAndConstantFoldingBuilder();
            var x           = GetVarAndIdExpr("x", BasicType.Int).Item2;
            var y           = GetVarAndIdExpr("y", BasicType.Int).Item2;
            var z           = GetVarAndIdExpr("z", BasicType.Int).Item2;
            var cfb         = builderPair.Item2;
            var result      = cfb.Div(cfb.Div(x, y), z);
            var asDiv       = ExprUtil.AsDiv(result);

            Assert.IsNotNull(asDiv);
            CheckIsInt(result);
            Assert.AreSame(x, asDiv.Args[0]);
            var rhsOfDiv = ExprUtil.AsMul(asDiv.Args[1]);

            Assert.IsNotNull(rhsOfDiv);
            Assert.AreSame(y, rhsOfDiv.Args[0]);
            Assert.AreSame(z, rhsOfDiv.Args[1]);
        }