public void nestedNegs(int depth) { var pair = GetVarAndIdExpr("foo", BasicType.GetBvType(8)); var variable = pair.Item1; var id = pair.Item2; var cfb = GetConstantFoldingBuilder(); Expr result = id; for (int i = 0; i < depth; ++i) { result = cfb.BVNEG(result); CheckIsBvType(result, 8); } if (depth % 2 == 0) { Assert.AreSame(id, result); } else { var asBvNeg = ExprUtil.AsBVNEG(result); Assert.IsNotNull(asBvNeg); Assert.AreSame(id, asBvNeg.Args[0]); } }
public void lhsIsZero() { var cfb = GetConstantFoldingBuilder(); var x = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2; var result = cfb.BVSUB(cfb.ConstantBV(0, 8), x); CheckIsBvType(result, 8); var asBvNeg = ExprUtil.AsBVNEG(result); Assert.IsNotNull(asBvNeg); Assert.AreSame(x, asBvNeg.Args[0]); }
public void noFold() { var pair = GetSimpleAndConstantFoldingBuilder(); var sb = pair.Item1; var cfb = pair.Item2; var id = GetVarAndIdExpr("foo", BasicType.GetBvType(8)).Item2; var foldedResult = cfb.BVNEG(id); var simpleResult = sb.BVNEG(id); CheckIsBvType(foldedResult, 8); CheckIsBvType(simpleResult, 8); Assert.AreEqual(simpleResult, foldedResult); var asBvNeg = ExprUtil.AsBVNEG(foldedResult); Assert.IsNotNull(asBvNeg); Assert.AreSame(id, asBvNeg.Args[0]); }