Search in sources :

Example 1 with PInvariant

use of de.be4.eventb.core.parser.node.PInvariant 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());
}
Also used : Start(de.be4.eventbalg.core.parser.node.Start) PInvariant(de.be4.eventbalg.core.parser.node.PInvariant) AInvariant(de.be4.eventbalg.core.parser.node.AInvariant) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 2 with PInvariant

use of de.be4.eventb.core.parser.node.PInvariant 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());
}
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) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 3 with PInvariant

use of de.be4.eventb.core.parser.node.PInvariant 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());
}
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) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 4 with PInvariant

use of de.be4.eventb.core.parser.node.PInvariant 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());
}
Also used : Start(de.be4.eventbalg.core.parser.node.Start) PInvariant(de.be4.eventbalg.core.parser.node.PInvariant) AInvariant(de.be4.eventbalg.core.parser.node.AInvariant) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 5 with PInvariant

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

Aggregations

Test (org.junit.Test)10 AInvariant (de.be4.eventb.core.parser.node.AInvariant)5 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)5 PInvariant (de.be4.eventb.core.parser.node.PInvariant)5 Start (de.be4.eventb.core.parser.node.Start)5 AInvariant (de.be4.eventbalg.core.parser.node.AInvariant)5 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)5 PInvariant (de.be4.eventbalg.core.parser.node.PInvariant)5 Start (de.be4.eventbalg.core.parser.node.Start)5 TComment (de.be4.eventb.core.parser.node.TComment)3 TComment (de.be4.eventbalg.core.parser.node.TComment)3 StringTokenizer (java.util.StringTokenizer)2