Search in sources :

Example 1 with AVariable

use of de.be4.eventbalg.core.parser.node.AVariable 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());
}
Also used : AVariable(de.be4.eventbalg.core.parser.node.AVariable) StringTokenizer(java.util.StringTokenizer) Start(de.be4.eventbalg.core.parser.node.Start) TComment(de.be4.eventbalg.core.parser.node.TComment) PVariable(de.be4.eventbalg.core.parser.node.PVariable) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 2 with AVariable

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

the class StructureTest method testIdentifierTick.

@Test
public void testIdentifierTick() throws Exception {
    final Start root = parseInput("machine Mac variables x' y end", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
    final LinkedList<PVariable> variables = parseUnit.getVariables();
    assertEquals(2, variables.size());
    assertEquals("x'", ((AVariable) variables.get(0)).getName().getText());
    assertEquals("y", ((AVariable) variables.get(1)).getName().getText());
}
Also used : AVariable(de.be4.eventbalg.core.parser.node.AVariable) Start(de.be4.eventbalg.core.parser.node.Start) PVariable(de.be4.eventbalg.core.parser.node.PVariable) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 3 with AVariable

use of de.be4.eventbalg.core.parser.node.AVariable 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());
}
Also used : AVariable(de.be4.eventb.core.parser.node.AVariable) StringTokenizer(java.util.StringTokenizer) Start(de.be4.eventb.core.parser.node.Start) TComment(de.be4.eventb.core.parser.node.TComment) PVariable(de.be4.eventb.core.parser.node.PVariable) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 4 with AVariable

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

the class StructureTest method testIdentifierTick.

@Test
public void testIdentifierTick() throws Exception {
    final Start root = parseInput("machine Mac variables x' y end", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
    final LinkedList<PVariable> variables = parseUnit.getVariables();
    assertEquals(2, variables.size());
    assertEquals("x'", ((AVariable) variables.get(0)).getName().getText());
    assertEquals("y", ((AVariable) variables.get(1)).getName().getText());
}
Also used : AVariable(de.be4.eventb.core.parser.node.AVariable) Start(de.be4.eventb.core.parser.node.Start) PVariable(de.be4.eventb.core.parser.node.PVariable) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)2 AVariable (de.be4.eventb.core.parser.node.AVariable)2 PVariable (de.be4.eventb.core.parser.node.PVariable)2 Start (de.be4.eventb.core.parser.node.Start)2 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)2 AVariable (de.be4.eventbalg.core.parser.node.AVariable)2 PVariable (de.be4.eventbalg.core.parser.node.PVariable)2 Start (de.be4.eventbalg.core.parser.node.Start)2 StringTokenizer (java.util.StringTokenizer)2 TComment (de.be4.eventb.core.parser.node.TComment)1 TComment (de.be4.eventbalg.core.parser.node.TComment)1