Search in sources :

Example 21 with MachineNode

use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.

the class LTLMachineTest method testSimpleLTLTestMachine.

@Test
public void testSimpleLTLTestMachine() {
    MachineNode machine = new MachineBuilder().setName("SimpleLTLTestMachine").setDefinitions("ASSERT_LTL_1 == \"F({x=7})\"").setVariables("x").setInvariant("x : 1..10").setInitialization("x := 1").addOperation("foo = SELECT x < 5 THEN x := x + 1 END").build();
    assertNotNull(machine);
    List<LTLFormula> ltlFormulas = machine.getLTLFormulas();
    LTLFormula ltl1 = ltlFormulas.get(0);
    assertEquals("ASSERT_LTL_1", ltl1.getName());
}
Also used : LTLFormula(de.bmoth.parser.ast.nodes.ltl.LTLFormula) MachineNode(de.bmoth.parser.ast.nodes.MachineNode) Test(org.junit.Test)

Example 22 with MachineNode

use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.

the class LiftsTest method testCrashing.

@Test
public void testCrashing() {
    MachineNode simpleMachineWithViolation = parseMachineFromFile(dir + "CrashingLift.mch");
    ModelCheckingResult result = ExplicitStateModelChecker.check(simpleMachineWithViolation);
    assertEquals(false, result.isCorrect());
    assertEquals("{old_floor=3, old_time=3, current_time=4, current_floor=0}", result.getLastState().toString());
}
Also used : MachineNode(de.bmoth.parser.ast.nodes.MachineNode) ModelCheckingResult(de.bmoth.modelchecker.ModelCheckingResult) Test(org.junit.Test)

Example 23 with MachineNode

use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.

the class LiftsTest method testNotMoving.

@Test
public void testNotMoving() {
    MachineNode simpleMachineWithViolation = parseMachineFromFile(dir + "NotMoving.mch");
    ModelCheckingResult result = ExplicitStateModelChecker.check(simpleMachineWithViolation);
    assertEquals(false, result.isCorrect());
}
Also used : MachineNode(de.bmoth.parser.ast.nodes.MachineNode) ModelCheckingResult(de.bmoth.modelchecker.ModelCheckingResult) Test(org.junit.Test)

Example 24 with MachineNode

use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.

the class LiftsTest method testTargetAndCurrentCorrespond.

@Test
public void testTargetAndCurrentCorrespond() {
    MachineNode simpleMachineWithViolation = parseMachineFromFile(dir + "TargetAndCurrentCorrespond.mch");
    ModelCheckingResult result = ExplicitStateModelChecker.check(simpleMachineWithViolation);
    assertEquals(false, result.isCorrect());
    Expr targetFloor = result.getLastState().getValues().get("target_floor");
    Expr currentFloor = result.getLastState().getValues().get("current_floor");
    assertNotEquals(targetFloor.toString(), currentFloor.toString());
}
Also used : Expr(com.microsoft.z3.Expr) MachineNode(de.bmoth.parser.ast.nodes.MachineNode) ModelCheckingResult(de.bmoth.modelchecker.ModelCheckingResult) Test(org.junit.Test)

Example 25 with MachineNode

use of de.bmoth.parser.ast.nodes.MachineNode in project bmoth by hhu-stups.

the class LiftsTest method testOpenDoorWhileMoving.

@Test
public void testOpenDoorWhileMoving() {
    MachineNode simpleMachineWithViolation = parseMachineFromFile(dir + "OpenDoorWhileMoving.mch");
    ModelCheckingResult result = ExplicitStateModelChecker.check(simpleMachineWithViolation);
    assertEquals(false, result.isCorrect());
    assertEquals("{doors_open=true, moving=true}", result.getLastState().toString());
}
Also used : MachineNode(de.bmoth.parser.ast.nodes.MachineNode) ModelCheckingResult(de.bmoth.modelchecker.ModelCheckingResult) Test(org.junit.Test)

Aggregations

MachineNode (de.bmoth.parser.ast.nodes.MachineNode)30 Test (org.junit.Test)25 ModelCheckingResult (de.bmoth.modelchecker.ModelCheckingResult)22 ParserException (de.bmoth.parser.ParserException)2 DeclarationNode (de.bmoth.parser.ast.nodes.DeclarationNode)2 Expr (com.microsoft.z3.Expr)1 BMoThParser (de.bmoth.antlr.BMoThParser)1 LtlStartContext (de.bmoth.antlr.BMoThParser.LtlStartContext)1 StartContext (de.bmoth.antlr.BMoThParser.StartContext)1 SemanticAstCreator (de.bmoth.parser.ast.SemanticAstCreator)1 TypeErrorException (de.bmoth.parser.ast.TypeErrorException)1 AnySubstitutionNode (de.bmoth.parser.ast.nodes.AnySubstitutionNode)1 OperationNode (de.bmoth.parser.ast.nodes.OperationNode)1 LTLFormula (de.bmoth.parser.ast.nodes.ltl.LTLFormula)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringJoiner (java.util.StringJoiner)1 Ignore (org.junit.Ignore)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1