public void testExecute1() { IntVar var = C.addIntVar(0, 10, "var", IntVar.DOMAIN_PLAIN); class GoalSuccess extends GoalImpl { GoalSuccess() { super(C, "GoalSuccess"); } public Goal execute() throws Failure { return null; } } class GoalOutput extends GoalImpl { private String _str = null; GoalOutput(String str) { super(C, ""); _str = str; } public Goal execute() throws Failure { fail(_str); return null; } } assertTrue(C.execute(new GoalAnd(new GoalSetMin(var, 2), new GoalSetMax(var, 8)))); assertTrue((var.min() == 2) && (var.max() == 8)); assertTrue(!C.execute(new GoalAnd(new GoalSetMin(var, 5), new GoalSetMax(var, 4)))); assertTrue(!C.execute(new GoalAnd(new GoalFail(C), new GoalSuccess()))); assertTrue( !C.execute( new GoalAnd( new GoalFail(C), new GoalOutput( "Test Failed:" + "Both subgoals of GoalAnd has been executed despite the fact that the first subgoal failed")))); }