Search in sources :

Example 16 with RulesMachineRun

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

Example 17 with RulesMachineRun

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

Example 18 with RulesMachineRun

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

Example 19 with RulesMachineRun

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

Example 20 with RulesMachineRun

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

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