@Test
public void complexity() throws IOException {

    final CharStream charStream = CharStreams.fromStream(this.getClass().getResourceAsStream("/dart/complexity.dart"));
    final Dart2Lexer lexer = new Dart2Lexer(charStream);
    lexer.removeErrorListeners();
    final CommonTokenStream stream = new CommonTokenStream(lexer);
    stream.fill();
    final Dart2Parser parser = new Dart2Parser(stream);
    parser.removeErrorListeners();
    final ParseTree root = parser.compilationUnit();
    CyclomaticComplexityVisitor visitor = new CyclomaticComplexityVisitor();
    CustomTreeVisitor customTreeVisitor = new CustomTreeVisitor(visitor);
    customTreeVisitor.visit(root);
    assertThat(visitor.getComplexity()).isEqualTo(7);
}