Search in sources :

Example 1 with AEvent

use of de.be4.classicalb.core.parser.node.AEvent in project probparsers by bendisposto.

the class CommentTest method testAtSignInComment.

@Test
public void testAtSignInComment() throws Exception {
    final Start rootNode = parseInput("machine AtSignInComment\nevents\nevent testEvent\nthen\n@act1 skip\n@act2 skip\n// MyComment@act2\nend\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
    final AEvent event = (AEvent) parseUnit.getEvents().get(0);
    final LinkedList<PAction> actions = event.getActions();
    AAction labeledAction = (AAction) actions.get(0);
    assertEquals("act1", labeledAction.getName().getText());
    assertEquals("skip", labeledAction.getAction().getText());
    assertEquals(0, labeledAction.getComments().size());
    labeledAction = (AAction) actions.get(1);
    assertEquals("act2", labeledAction.getName().getText());
    assertEquals("skip", labeledAction.getAction().getText());
    assertNotNull(labeledAction.getComments());
    assertEquals("MyComment@act2", labeledAction.getComments().get(0).getText());
}
Also used : PAction(de.be4.eventbalg.core.parser.node.PAction) Start(de.be4.eventbalg.core.parser.node.Start) AEvent(de.be4.eventbalg.core.parser.node.AEvent) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) AAction(de.be4.eventbalg.core.parser.node.AAction) Test(org.junit.Test)

Example 2 with AEvent

use of de.be4.classicalb.core.parser.node.AEvent in project probparsers by bendisposto.

the class StructureTest method testWitnessTick.

@Test
public void testWitnessTick() throws Exception {
    final Start root = parseInput("machine WitnessTick\nevents\nevent Eve\nwith\n@x' x' :: NAT\nend\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
    final LinkedList<PEvent> events = parseUnit.getEvents();
    assertEquals(1, events.size());
    final AEvent event = (AEvent) events.get(0);
    final LinkedList<PWitness> witnesses = event.getWitnesses();
    assertEquals(1, witnesses.size());
    assertEquals("x'", ((AWitness) witnesses.get(0)).getName().getText());
}
Also used : Start(de.be4.eventb.core.parser.node.Start) AWitness(de.be4.eventb.core.parser.node.AWitness) PWitness(de.be4.eventb.core.parser.node.PWitness) AEvent(de.be4.eventb.core.parser.node.AEvent) PEvent(de.be4.eventb.core.parser.node.PEvent) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 3 with AEvent

use of de.be4.classicalb.core.parser.node.AEvent in project prob2 by bendisposto.

the class MachineExtractor method caseAEvent.

@Override
public void caseAEvent(final AEvent node) {
    EventExtractor eE = new EventExtractor(new Event(node.getName().getText(), EventType.ORDINARY, false), machineM.getMachine().getRefines(), typeEnv, getComment(node.getComments()));
    node.apply(eE);
    machineM = new MachineModifier(machineM.getMachine().addTo(BEvent.class, eE.getEvent()), typeEnv);
}
Also used : BEvent(de.prob.model.representation.BEvent) AEvent(de.be4.eventbalg.core.parser.node.AEvent) Event(de.prob.model.eventb.Event) MachineModifier(de.prob.model.eventb.MachineModifier)

Example 4 with AEvent

use of de.be4.classicalb.core.parser.node.AEvent in project probparsers by bendisposto.

the class ASTPrologTest method testEvent.

@Test
public void testEvent() throws BCompoundException {
    final AEventBModelParseUnit model = new AEventBModelParseUnit();
    model.setName(new TIdentifierLiteral("mm"));
    final AEventsModelClause events = new AEventsModelClause();
    model.setModelClauses(Arrays.asList((PModelClause) events));
    AEvent event = new AEvent();
    events.setEvent(Arrays.asList((PEvent) event));
    event.setEventName(new TIdentifierLiteral("testevent"));
    event.setVariables(Arrays.asList(createId("param")));
    event.setGuards(Arrays.asList((PPredicate) new ATruthPredicate()));
    PSubstitution subst1 = new AAssignSubstitution(Arrays.asList(createId("x")), Arrays.asList(createId("param")));
    event.setAssignments(Arrays.asList(subst1));
    PWitness witness = new AWitness(new TIdentifierLiteral("ab"), new AEqualPredicate(createId("ab"), createId("y")));
    event.setWitness(Arrays.asList(witness));
    event.setRefines(Arrays.asList(new TIdentifierLiteral("abstract1"), new TIdentifierLiteral("abstract2")));
    checkAST(0, "event_b_model($,mm,[events($,[" + "event($,testevent,[abstract1,abstract2],[identifier($,param)],[truth($)],[]," + "[assign($,[identifier($,x)],[identifier($,param)])]," + "[witness($,identifier(%,ab),equal($,identifier($,ab),identifier($,y)))])])])", model);
}
Also used : AEqualPredicate(de.be4.classicalb.core.parser.node.AEqualPredicate) PModelClause(de.be4.classicalb.core.parser.node.PModelClause) PPredicate(de.be4.classicalb.core.parser.node.PPredicate) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral) PEvent(de.be4.classicalb.core.parser.node.PEvent) AEventBModelParseUnit(de.be4.classicalb.core.parser.node.AEventBModelParseUnit) AWitness(de.be4.classicalb.core.parser.node.AWitness) PSubstitution(de.be4.classicalb.core.parser.node.PSubstitution) PWitness(de.be4.classicalb.core.parser.node.PWitness) AEvent(de.be4.classicalb.core.parser.node.AEvent) ATruthPredicate(de.be4.classicalb.core.parser.node.ATruthPredicate) AEventsModelClause(de.be4.classicalb.core.parser.node.AEventsModelClause) AAssignSubstitution(de.be4.classicalb.core.parser.node.AAssignSubstitution) Test(org.junit.Test)

Example 5 with AEvent

use of de.be4.classicalb.core.parser.node.AEvent in project probparsers by bendisposto.

the class StructureTest method testWitnessTick.

@Test
public void testWitnessTick() throws Exception {
    final Start root = parseInput("machine WitnessTick\nevents\nevent Eve\nwith\n@x' x' :: NAT\nend\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
    final LinkedList<PEvent> events = parseUnit.getEvents();
    assertEquals(1, events.size());
    final AEvent event = (AEvent) events.get(0);
    final LinkedList<PWitness> witnesses = event.getWitnesses();
    assertEquals(1, witnesses.size());
    assertEquals("x'", ((AWitness) witnesses.get(0)).getName().getText());
}
Also used : Start(de.be4.eventbalg.core.parser.node.Start) AWitness(de.be4.eventbalg.core.parser.node.AWitness) PWitness(de.be4.eventbalg.core.parser.node.PWitness) AEvent(de.be4.eventbalg.core.parser.node.AEvent) PEvent(de.be4.eventbalg.core.parser.node.PEvent) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 AEvent (de.be4.eventbalg.core.parser.node.AEvent)3 AEvent (de.be4.classicalb.core.parser.node.AEvent)2 AEventsModelClause (de.be4.classicalb.core.parser.node.AEventsModelClause)2 AWitness (de.be4.classicalb.core.parser.node.AWitness)2 PEvent (de.be4.classicalb.core.parser.node.PEvent)2 PPredicate (de.be4.classicalb.core.parser.node.PPredicate)2 PSubstitution (de.be4.classicalb.core.parser.node.PSubstitution)2 PWitness (de.be4.classicalb.core.parser.node.PWitness)2 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)2 AEvent (de.be4.eventb.core.parser.node.AEvent)2 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)2 Start (de.be4.eventb.core.parser.node.Start)2 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)2 Start (de.be4.eventbalg.core.parser.node.Start)2 Event (de.prob.model.eventb.Event)2 AAssignSubstitution (de.be4.classicalb.core.parser.node.AAssignSubstitution)1 AEqualPredicate (de.be4.classicalb.core.parser.node.AEqualPredicate)1 AEventBModelParseUnit (de.be4.classicalb.core.parser.node.AEventBModelParseUnit)1 ATruthPredicate (de.be4.classicalb.core.parser.node.ATruthPredicate)1