use of org.sonar.plugins.java.api.tree.BreakStatementTree in project sonar-java by SonarSource.
the class JavaTreeModelTest method break_statement.
/**
* 14.15. The break Statement
*/
@Test
public void break_statement() {
BreakStatementTree tree = (BreakStatementTree) firstMethodFirstStatement("class T { void m() { break ; } }");
assertThat(tree.is(Tree.Kind.BREAK_STATEMENT)).isTrue();
assertThat(tree.breakKeyword().text()).isEqualTo("break");
assertThat(tree.label()).isNull();
assertThat(tree.semicolonToken().text()).isEqualTo(";");
assertThatChildrenIteratorHasSize(tree, 2);
tree = (BreakStatementTree) firstMethodFirstStatement("class T { void m() { break label ; } }");
assertThat(tree.is(Tree.Kind.BREAK_STATEMENT)).isTrue();
assertThat(tree.breakKeyword().text()).isEqualTo("break");
assertThat(tree.label().name()).isEqualTo("label");
assertThat(tree.semicolonToken().text()).isEqualTo(";");
assertThatChildrenIteratorHasSize(tree, 3);
}
Aggregations