use of de.be4.eventb.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class CommentTest method testMultipleComments1.
@Test
public void testMultipleComments1() throws Exception {
final Start rootNode = parseInput("machine MultipleComments1" + "// 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());
}
use of de.be4.eventb.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class CommentTest method testCommentVariables1.
@Test
public void testCommentVariables1() throws Exception {
final Start rootNode = parseInput("machine CommentVariables1 variables\n" + "varA" + "//varA comment\n" + " varB\n" + "varC\n" + "/*varC\ncomment*/" + "end", false);
final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
final LinkedList<PVariable> variables = parseUnit.getVariables();
assertEquals(3, variables.size());
AVariable variable = (AVariable) variables.get(0);
assertEquals("varA", variable.getName().getText());
assertEquals("varA comment", variable.getComments().get(0).getText());
variable = (AVariable) variables.get(1);
assertEquals("varB", variable.getName().getText());
assertEquals(0, variable.getComments().size());
variable = (AVariable) variables.get(2);
assertEquals("varC", variable.getName().getText());
final LinkedList<TComment> comments = variable.getComments();
assertNotNull(comments);
assertEquals(1, comments.size());
final StringTokenizer tokenizer = new StringTokenizer(comments.get(0).getText(), "\n\r");
assertEquals(2, tokenizer.countTokens());
assertEquals("varC", tokenizer.nextToken());
assertEquals("comment", tokenizer.nextToken());
}
use of de.be4.eventb.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class CommentTest method testCommentPredicates1.
@Test
public void testCommentPredicates1() throws Exception {
final Start rootNode = parseInput("machine CommentPredicates1 invariants\n @inv1 asdf //MyComment\nend", false);
final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
final LinkedList<PInvariant> invariants = parseUnit.getInvariants();
final AInvariant invariant = (AInvariant) invariants.get(0);
// correct comment content?
assertEquals("MyComment", invariant.getComments().get(0).getText());
}
use of de.be4.eventb.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());
}
use of de.be4.eventb.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());
}
Aggregations