Пример #1
0
  @Test
  public void testFindNextCharSequenceWithEmptyBlock() {
    final StateParser parser = new StateParser();

    parser.findNext("state init {}");
    Assert.assertTrue(parser.hasFoundElement());
    Assert.assertEquals("state init {}", parser.getLastFoundStatement());
    final StateNode lastFoundAsNode = parser.getLastFoundAsNode();
    Assert.assertEquals(StateNode.class, lastFoundAsNode.getClass());
    Assert.assertEquals("init", lastFoundAsNode.getSourceIdentifier());
    Assert.assertTrue(lastFoundAsNode.hasOffsets());
    Assert.assertEquals(0, lastFoundAsNode.getStatementStartOffset());
    Assert.assertEquals(12, lastFoundAsNode.getStatementEndOffset());

    Assert.assertEquals(parser.getEndOffsetLastFound(), lastFoundAsNode.getStatementEndOffset());
  }
Пример #2
0
  @Test
  public void testFindNextCharSequence() {
    final StateParser parser = new StateParser();

    parser.findNext(this._source);
    Assert.assertTrue(parser.hasFoundElement());
    Assert.assertEquals(
        "state init {"
            + "	when (delay(0.1)) {"
            + "	    printf(\"sncExample: Startup delay over\n\");"
            + "	} state low"
            + "    }",
        parser.getLastFoundStatement());
    final StateNode lastFoundAsNode = parser.getLastFoundAsNode();
    Assert.assertEquals(StateNode.class, lastFoundAsNode.getClass());
    Assert.assertEquals("init", lastFoundAsNode.getSourceIdentifier());
    Assert.assertTrue(lastFoundAsNode.hasOffsets());
    Assert.assertEquals(123, lastFoundAsNode.getStatementStartOffset());
    Assert.assertEquals(218, lastFoundAsNode.getStatementEndOffset());

    Assert.assertEquals(parser.getEndOffsetLastFound(), lastFoundAsNode.getStatementEndOffset());
  }