Search in sources :

Example 6 with RulesMachineRun

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());
}
Also used : RulesMachineRun(de.prob.model.brules.RulesMachineRun) RuleResult(de.prob.model.brules.RuleResult) Test(org.junit.Test)

Example 7 with RulesMachineRun

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());
}
Also used : RulesMachineRun(de.prob.model.brules.RulesMachineRun) Test(org.junit.Test)

Example 8 with RulesMachineRun

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());
}
Also used : RulesMachineRun(de.prob.model.brules.RulesMachineRun) HashMap(java.util.HashMap) File(java.io.File) Test(org.junit.Test)

Example 9 with RulesMachineRun

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;
}
Also used : RulesMachineRun(de.prob.model.brules.RulesMachineRun)

Example 10 with 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);
}
Also used : RulesMachineRun(de.prob.model.brules.RulesMachineRun) BException(de.be4.classicalb.core.parser.exceptions.BException) Test(org.junit.Test)

Aggregations

RulesMachineRun (de.prob.model.brules.RulesMachineRun)20 Test (org.junit.Test)18 File (java.io.File)6 RuleResult (de.prob.model.brules.RuleResult)3 HashMap (java.util.HashMap)2 BException (de.be4.classicalb.core.parser.exceptions.BException)1 RuleOperation (de.be4.classicalb.core.parser.rules.RuleOperation)1 ComputationStatuses (de.prob.model.brules.ComputationStatuses)1 CounterExample (de.prob.model.brules.RuleResult.CounterExample)1 RuleResults (de.prob.model.brules.RuleResults)1 ResultSummary (de.prob.model.brules.RuleResults.ResultSummary)1 State (de.prob.statespace.State)1 BigInteger (java.math.BigInteger)1