Search in sources :

Example 21 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit 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)

Example 22 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.

the class CommentTest method testMultipleComments2.

@Test
public void testMultipleComments2() throws Exception {
    final Start rootNode = parseInput("machine MultipleComments2" + "/* line1*/\n" + "/* line2\nline3*/" + "// line4\n" + "\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
    final LinkedList<TComment> comments = parseUnit.getComments();
    assertEquals(3, comments.size());
    assertEquals("line1", comments.get(0).getText());
    assertEquals("line2\nline3", comments.get(1).getText());
    assertEquals("line4", comments.get(2).getText());
}
Also used : Start(de.be4.eventb.core.parser.node.Start) TComment(de.be4.eventb.core.parser.node.TComment) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 23 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.

the class CommentTest method testMultiLineMachineComment.

@Test
public void testMultiLineMachineComment() throws Exception {
    final Start rootNode = parseInput("machine MultiLineMachineComment" + "/*\n" + " comment\n" + " in multiple\n" + " lines\n" + "*/\n" + " end", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
    final String comments = parseUnit.getComments().get(0).getText();
    final StringTokenizer tokenizer = new StringTokenizer(comments, "\n\r");
    assertEquals(3, tokenizer.countTokens());
    assertEquals(" comment", tokenizer.nextToken());
    assertEquals(" in multiple", tokenizer.nextToken());
    assertEquals(" lines", tokenizer.nextToken());
}
Also used : StringTokenizer(java.util.StringTokenizer) Start(de.be4.eventb.core.parser.node.Start) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 24 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit 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.eventb.core.parser.node.PAction) Start(de.be4.eventb.core.parser.node.Start) AEvent(de.be4.eventb.core.parser.node.AEvent) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) AAction(de.be4.eventb.core.parser.node.AAction) Test(org.junit.Test)

Example 25 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.

the class CommentTest method testCommentPredicates2.

@Test
public void testCommentPredicates2() throws Exception {
    final Start rootNode = parseInput("machine CommentPredicates2 invariants\n @inv0 asdf\n @inv1 asdf\n//MyComment\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
    final LinkedList<PInvariant> invariants = parseUnit.getInvariants();
    assertEquals(2, invariants.size());
    AInvariant invariant = (AInvariant) invariants.get(0);
    assertEquals(0, invariant.getComments().size());
    assertEquals("inv0", invariant.getName().getText());
    assertEquals("asdf", invariant.getPredicate().getText());
    // correct comment content, i.e., is whitespace in the beginning
    // omitted?
    invariant = (AInvariant) invariants.get(1);
    final LinkedList<TComment> comments = invariant.getComments();
    assertEquals(1, comments.size());
    assertEquals("MyComment", comments.get(0).getText());
    assertEquals("inv1", invariant.getName().getText());
    assertEquals("asdf", invariant.getPredicate().getText());
}
Also used : Start(de.be4.eventb.core.parser.node.Start) PInvariant(de.be4.eventb.core.parser.node.PInvariant) AInvariant(de.be4.eventb.core.parser.node.AInvariant) TComment(de.be4.eventb.core.parser.node.TComment) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)28 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)14 Start (de.be4.eventb.core.parser.node.Start)14 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)14 Start (de.be4.eventbalg.core.parser.node.Start)14 TComment (de.be4.eventb.core.parser.node.TComment)6 TComment (de.be4.eventbalg.core.parser.node.TComment)6 StringTokenizer (java.util.StringTokenizer)6 AInvariant (de.be4.eventb.core.parser.node.AInvariant)5 PInvariant (de.be4.eventb.core.parser.node.PInvariant)5 AInvariant (de.be4.eventbalg.core.parser.node.AInvariant)5 PInvariant (de.be4.eventbalg.core.parser.node.PInvariant)5 PVariable (de.be4.eventb.core.parser.node.PVariable)3 PVariable (de.be4.eventbalg.core.parser.node.PVariable)3 AEvent (de.be4.eventb.core.parser.node.AEvent)2 AVariable (de.be4.eventb.core.parser.node.AVariable)2 AEvent (de.be4.eventbalg.core.parser.node.AEvent)2 AVariable (de.be4.eventbalg.core.parser.node.AVariable)2 PositionedNode (de.hhu.stups.sablecc.patch.PositionedNode)2 AAction (de.be4.eventb.core.parser.node.AAction)1