use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineErrorsTest method testEnumerationError.
@Test
public void testEnumerationError() {
RulesMachineRun rulesMachineRun = startRulesMachineRunWithOperations("RULE foo BODY RULE_FORALL x WHERE 1=1 EXPECT x = \"foo\" COUNTEREXAMPLE x END END");
assertTrue(null != rulesMachineRun.getFirstError());
assertEquals(ERROR_TYPES.PROB_ERROR, rulesMachineRun.getFirstError().getType());
assertTrue(rulesMachineRun.getTotalNumberOfProBCliErrors().intValue() > 0);
assertTrue(rulesMachineRun.getErrorList().size() > 0);
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineErrorsTest method testRulesMachineWithWDError.
@Test
public void testRulesMachineWithWDError() {
// @formatter:off
RulesMachineRun rulesMachineRun = startRulesMachineRunWithOperations("RULE Rule1 BODY VAR xx IN xx := {1|->2}(3) END;RULE_FAIL COUNTEREXAMPLE \"fail\" END END", "RULE Rule2 DEPENDS_ON_RULE Rule1 BODY RULE_FAIL COUNTEREXAMPLE \"fail\" END END");
System.out.println(rulesMachineRun.getFirstError());
// @formatter:on
assertTrue(rulesMachineRun.hasError());
int numberofStatesExecuted = rulesMachineRun.getExecuteRun().getExecuteModelCommand().getNumberofStatesExecuted();
assertEquals(1, numberofStatesExecuted);
assertEquals(ERROR_TYPES.PROB_ERROR, rulesMachineRun.getFirstError().getType());
assertTrue(rulesMachineRun.getTotalNumberOfProBCliErrors().intValue() > 0);
System.out.println(rulesMachineRun.getRuleResults());
// Rule1 is not checked because of the WD Error
assertEquals(RuleStatus.NOT_CHECKED, rulesMachineRun.getRuleResults().getRuleResult("Rule1").getRuleState());
// Rule2 is not checked because of the dependency to Rule1
assertEquals(RuleStatus.NOT_CHECKED, rulesMachineRun.getRuleResults().getRuleResult("Rule2").getRuleState());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineTest method testRulesMachineExample.
@Test
public void testRulesMachineExample() {
RulesMachineRun rulesMachineRun = startRulesMachineRun(dir + "RulesMachineExample.rmch");
assertEquals(false, rulesMachineRun.hasError());
State finalState = rulesMachineRun.getExecuteRun().getExecuteModelCommand().getFinalState();
ComputationStatuses compResult = new ComputationStatuses(rulesMachineRun.getRulesProject(), finalState);
assertEquals(ComputationStatus.EXECUTED, compResult.getResult("COMP_comp1"));
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineTest method testExtractingAllCounterExample.
@Test
public void testExtractingAllCounterExample() {
File file = createRulesMachineFile("OPERATIONS RULE Rule1 BODY RULE_FAIL x WHEN x : 1..1000 COUNTEREXAMPLE STRING_FORMAT(\"This is a long counter example message including a unique number to test that the extracted B value will not be truncated: ~w\", x) END END");
RulesMachineRun rulesMachineRun = new RulesMachineRun(file);
rulesMachineRun.setMaxNumberOfReportedCounterExamples(1000);
rulesMachineRun.start();
System.out.println(rulesMachineRun.getRuleResults().getRuleResult("Rule1").getCounterExamples());
assertEquals(1000, rulesMachineRun.getRuleResults().getRuleResult("Rule1").getCounterExamples().size());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineTest method testReuseStateSpace.
@Test
public void testReuseStateSpace() throws IOException {
String ruleWithWDError = "RULE Rule1 BODY VAR xx IN xx := {1|->2}(3) END;RULE_FAIL WHEN 1=2 COUNTEREXAMPLE \"fail\" END END";
RulesMachineRun rulesMachineRun = startRulesMachineRunWithOperations(ruleWithWDError);
BigInteger numberAfterFirstRun = rulesMachineRun.getTotalNumberOfProBCliErrors();
RulesMachineRun rulesMachineRun2 = new RulesMachineRun(RulesTestUtil.createRulesMachineFileContainingOperations(ruleWithWDError).getAbsoluteFile());
rulesMachineRun2.setStateSpace(rulesMachineRun.getStateSpace());
rulesMachineRun2.start();
BigInteger numberAfterSecondRun = rulesMachineRun2.getTotalNumberOfProBCliErrors();
assertTrue(numberAfterSecondRun.intValue() > numberAfterFirstRun.intValue());
}
Aggregations