(Context ctx)
| 721 | // / Some basic tests. |
| 722 | |
| 723 | void basicTests(Context ctx) throws TestFailedException |
| 724 | { |
| 725 | System.out.println("BasicTests"); |
| 726 | |
| 727 | Symbol fname = ctx.mkSymbol("f"); |
| 728 | Symbol x = ctx.mkSymbol("x"); |
| 729 | Symbol y = ctx.mkSymbol("y"); |
| 730 | |
| 731 | BoolSort bs = ctx.mkBoolSort(); |
| 732 | |
| 733 | Sort[] domain = { bs, bs }; |
| 734 | FuncDecl<BoolSort> f = ctx.mkFuncDecl(fname, domain, bs); |
| 735 | Expr<BoolSort> fapp = ctx.mkApp(f, ctx.mkConst(x, bs), ctx.mkConst(y, bs)); |
| 736 | |
| 737 | Expr<?>[] fargs2 = { ctx.mkFreshConst("cp", bs) }; |
| 738 | Sort[] domain2 = { bs }; |
| 739 | Expr<BoolSort> fapp2 = ctx.mkApp(ctx.mkFreshFuncDecl("fp", domain2, bs), fargs2); |
| 740 | |
| 741 | BoolExpr trivial_eq = ctx.mkEq(fapp, fapp); |
| 742 | BoolExpr nontrivial_eq = ctx.mkEq(fapp, fapp2); |
| 743 | |
| 744 | Goal g = ctx.mkGoal(true, false, false); |
| 745 | g.add(trivial_eq); |
| 746 | g.add(nontrivial_eq); |
| 747 | System.out.printf("Goal: %s%n", g); |
| 748 | |
| 749 | Solver solver = ctx.mkSolver(); |
| 750 | |
| 751 | solver.add(g.getFormulas()); |
| 752 | |
| 753 | if (solver.check() != Status.SATISFIABLE) |
| 754 | throw new TestFailedException(); |
| 755 | |
| 756 | ApplyResult ar = applyTactic(ctx, ctx.mkTactic("simplify"), g); |
| 757 | if (ar.getNumSubgoals() == 1 |
| 758 | && (ar.getSubgoals()[0].isDecidedSat() || ar.getSubgoals()[0] |
| 759 | .isDecidedUnsat())) |
| 760 | throw new TestFailedException(); |
| 761 | |
| 762 | ar = applyTactic(ctx, ctx.mkTactic("smt"), g); |
| 763 | if (ar.getNumSubgoals() != 1 || !ar.getSubgoals()[0].isDecidedSat()) |
| 764 | throw new TestFailedException(); |
| 765 | |
| 766 | g.add(ctx.mkEq(ctx.mkNumeral(1, ctx.mkBitVecSort(32)), |
| 767 | ctx.mkNumeral(2, ctx.mkBitVecSort(32)))); |
| 768 | ar = applyTactic(ctx, ctx.mkTactic("smt"), g); |
| 769 | if (ar.getNumSubgoals() != 1 || !ar.getSubgoals()[0].isDecidedUnsat()) |
| 770 | throw new TestFailedException(); |
| 771 | |
| 772 | Goal g2 = ctx.mkGoal(true, true, false); |
| 773 | ar = applyTactic(ctx, ctx.mkTactic("smt"), g2); |
| 774 | if (ar.getNumSubgoals() != 1 || !ar.getSubgoals()[0].isDecidedSat()) |
| 775 | throw new TestFailedException(); |
| 776 | |
| 777 | g2 = ctx.mkGoal(true, true, false); |
| 778 | g2.add(ctx.mkFalse()); |
| 779 | ar = applyTactic(ctx, ctx.mkTactic("smt"), g2); |
| 780 | if (ar.getNumSubgoals() != 1 || !ar.getSubgoals()[0].isDecidedUnsat()) |
no test coverage detected