use of org.sonar.plugins.python.api.tree.AwaitExpression in project sonar-python by SonarSource.
the class PythonTreeMakerTest method await_expression.
@Test
public void await_expression() {
setRootRule(PythonGrammar.TEST);
AwaitExpression expr = (AwaitExpression) parse("await x", treeMaker::expression);
assertThat(expr.getKind()).isEqualTo(Tree.Kind.AWAIT);
assertThat(expr.awaitToken().value()).isEqualTo("await");
assertThat(expr.expression().getKind()).isEqualTo(Tree.Kind.NAME);
assertThat(expr.children()).hasSize(2);
BinaryExpression awaitWithPower = binaryExpression("await a ** 3");
assertThat(awaitWithPower.getKind()).isEqualTo(Tree.Kind.POWER);
assertThat(awaitWithPower.leftOperand().getKind()).isEqualTo(Tree.Kind.AWAIT);
assertThat(awaitWithPower.rightOperand().getKind()).isEqualTo(Tree.Kind.NUMERIC_LITERAL);
}
Aggregations