use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class LexerTest method testStringLabeledElements.
@Test
public void testStringLabeledElements() throws BException {
final Start rootNode = parseInput("machine Test invariants \n\t@inv1 asdf \n fdsa \n\t@inv2 qwer: \t rewq \nend", false);
final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
final LinkedList<PInvariant> invariants = parseUnit.getInvariants();
AInvariant invariant = (AInvariant) invariants.get(0);
// correct invariant label?
assertEquals("inv1", invariant.getName().getText());
// correct string representation for predicate?
assertEquals("asdf \n fdsa", invariant.getPredicate().getText());
invariant = (AInvariant) invariants.get(1);
// correct invariant label?
assertEquals("inv2", invariant.getName().getText());
// correct string representation for predicate?
assertEquals("qwer: \t rewq", invariant.getPredicate().getText());
}
use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class CommentTest method testInvariantsAndMultiComments.
@Test
public void testInvariantsAndMultiComments() throws BException {
final String input = "machine InvariantsAndMultiComments invariants\n" + "@inv1 1=1\n" + "@inv2 2=2\n" + "/*inv2\ncomment*/\n" + "end";
final Start rootNode = parseInput(input, 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("inv1", invariant.getName().getText());
assertEquals("1=1", invariant.getPredicate().getText());
invariant = (AInvariant) invariants.get(1);
final LinkedList<TComment> comments = invariant.getComments();
assertEquals(1, comments.size());
assertEquals("inv2\ncomment", comments.get(0).getText());
assertEquals("inv2", invariant.getName().getText());
assertEquals("2=2", invariant.getPredicate().getText());
}
use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class CommentTest method testMultiLineComment.
@Test
public void testMultiLineComment() throws Exception {
final Start rootNode = parseInput("machine MultiLineComment invariants @inv1 asdf\n/* First line\n Second line*/\nend", false);
final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
final LinkedList<PInvariant> invariants = parseUnit.getInvariants();
final AInvariant invariant = (AInvariant) invariants.get(0);
// correct comment content?
final LinkedList<TComment> comments = invariant.getComments();
assertEquals(1, comments.size());
final StringTokenizer tokenizer = new StringTokenizer(comments.get(0).getText(), "\n\r");
assertEquals(2, tokenizer.countTokens());
assertEquals("First line", tokenizer.nextToken());
assertEquals(" Second line", tokenizer.nextToken());
// correct invariant label?
assertEquals("inv1", invariant.getName().getText());
// correct string representation for predicate?
assertEquals("asdf", invariant.getPredicate().getText());
}
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());
}
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());
}
Aggregations