use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineTest method testMachineWithFailingRuleSequence.
@Test
public void testMachineWithFailingRuleSequence() {
// @formatter:off
RulesMachineRun rulesMachineRun = startRulesMachineRunWithOperations("RULE Rule1 ERROR_TYPES 3 BODY " + " RULE_FAIL COUNTEREXAMPLE \"foo1\" END ;" + " RULE_FAIL ERROR_TYPE 2 COUNTEREXAMPLE \"foo2\" END ;" + " RULE_FAIL ERROR_TYPE 3 COUNTEREXAMPLE \"foo3\" END " + " END");
// @formatter:on
assertTrue(rulesMachineRun.getRuleResults().getRuleResult("Rule1").hasFailed());
assertEquals(3, rulesMachineRun.getRuleResults().getRuleResult("Rule1").getCounterExamples().size());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineErrorsTest method testRulesMachineWithTypeError.
@Test
public void testRulesMachineWithTypeError() {
RulesMachineRun rulesMachineRun = startRulesMachineRunWithOperations("RULE foo BODY VAR xx IN xx := 1; xx := TRUE END;RULE_FAIL COUNTEREXAMPLE \"fail\" END END");
System.out.println(rulesMachineRun.getFirstError());
assertEquals(ERROR_TYPES.PROB_ERROR, rulesMachineRun.getFirstError().getType());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineErrorsTest method testRulesMachineFileNotFound.
@Test
public void testRulesMachineFileNotFound() {
RulesMachineRun rulesMachineRun = startRulesMachineRun("RulesMachineFileDoesNotExist123.rmch");
assertEquals(ERROR_TYPES.PARSE_ERROR, rulesMachineRun.getFirstError().getType());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineErrorsTest method testContinueAfterError.
@Test
public void testContinueAfterError() {
File runnerFile = createRulesMachineFile("OPERATIONS RULE Rule1 BODY VAR xx IN xx := {1|->2}(3) END;RULE_FAIL WHEN 1=2 COUNTEREXAMPLE \"fail\" END END;" + "RULE Rule2 BODY VAR xx IN xx := {1|->2}(3) END;RULE_FAIL WHEN 1=2 COUNTEREXAMPLE \"fail\" END END;" + "RULE Rule3 BODY RULE_FAIL WHEN 1=2 COUNTEREXAMPLE \"fail\" END END");
RulesMachineRun rulesMachineRun = new RulesMachineRun(runnerFile);
rulesMachineRun.setContinueAfterErrors(true);
rulesMachineRun.start();
assertTrue(rulesMachineRun.getTotalNumberOfProBCliErrors().intValue() >= 2);
assertEquals(RuleStatus.SUCCESS, rulesMachineRun.getRuleResults().getRuleResult("Rule3").getRuleState());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesTestUtil method startRulesMachineRunWithOperations.
public static RulesMachineRun startRulesMachineRunWithOperations(String... operations) {
File machineFile = createRulesMachineFileContainingOperations(operations);
RulesMachineRun rulesMachineRun = startRulesMachineRun(machineFile.getAbsolutePath());
assertEquals(machineFile, rulesMachineRun.getRunnerFile());
return rulesMachineRun;
}
Aggregations