use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineTest method testReplaces.
@Test
public void testReplaces() {
RulesMachineRun rulesMachineRun = startRulesMachineRunWithOperations(" COMPUTATION COMP_comp1 BODY DEFINE V_Value1 TYPE INTEGER DUMMY_VALUE 0 VALUE 10 END END", " RULE RULE_BasedOnValue1 BODY RULE_FORALL x WHERE x : 1..V_Value1 EXPECT x <= 10 COUNTEREXAMPLE \"fail\" END END", " COMPUTATION COMP_NewComp1 REPLACES COMP_comp1 BODY DEFINE V_Value1 TYPE INTEGER DUMMY_VALUE 0 VALUE 12 END END");
RuleResult ruleResult = rulesMachineRun.getRuleResults().getRuleResult("RULE_BasedOnValue1");
assertTrue(ruleResult.hasFailed());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineTest method testNumberOfReportedCounterExamples.
@Test
public void testNumberOfReportedCounterExamples() {
RulesMachineRun rulesMachineRun = startRulesMachineRunWithOperations("RULE Rule1 BODY RULE_FAIL x WHEN x : 1..1000 COUNTEREXAMPLE STRING_FORMAT(\"~w\", x) END END");
// default value is 50
assertEquals(50, rulesMachineRun.getRuleResults().getRuleResult("Rule1").getCounterExamples().size());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineTest method testPreferences.
@Test
public void testPreferences() {
File file = createRulesMachineFile("OPERATIONS RULE Rule1 BODY RULE_FAIL x WHEN x : 1..MAXINT COUNTEREXAMPLE STRING_FORMAT(\"~w\", x) END END");
Map<String, String> prefs = new HashMap<>();
prefs.put("MAXINT", "12");
RulesMachineRun rulesMachineRun = new RulesMachineRun(file, prefs, Collections.<String, String>emptyMap());
rulesMachineRun.start();
assertEquals(12, rulesMachineRun.getRuleResults().getRuleResult("Rule1").getCounterExamples().size());
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesTestUtil method startRulesMachineRun.
public static RulesMachineRun startRulesMachineRun(File file) {
RulesMachineRun rulesMachineRun = new RulesMachineRun(file);
rulesMachineRun.start();
if (!rulesMachineRun.hasError()) {
checkRulesMachineRunForConsistency(rulesMachineRun);
}
return rulesMachineRun;
}
use of de.prob.model.brules.RulesMachineRun in project prob2 by bendisposto.
the class RulesMachineErrorsTest method testRulesMachineWithParseError.
@Test
public void testRulesMachineWithParseError() {
RulesMachineRun rulesMachineRun = startRulesMachineRunWithOperations("RULE foo BODY ;; END");
System.out.println(rulesMachineRun.getFirstError().getMessage());
assertEquals(ERROR_TYPES.PARSE_ERROR, rulesMachineRun.getFirstError().getType());
assertTrue(rulesMachineRun.getFirstError().getException() instanceof BException);
}
Aggregations