From 7511fd2c449cb5fe7630666d38a63ee58632ac9a Mon Sep 17 00:00:00 2001 From: summerji Date: Thu, 1 Oct 2020 11:35:45 -0700 Subject: [PATCH] Add assignment expr in exprStatement --- .../google/api/generator/engine/ast/ExprStatement.java | 1 + .../api/generator/engine/ast/ExprStatementTest.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/google/api/generator/engine/ast/ExprStatement.java b/src/main/java/com/google/api/generator/engine/ast/ExprStatement.java index 7749da18cc..341b57192f 100644 --- a/src/main/java/com/google/api/generator/engine/ast/ExprStatement.java +++ b/src/main/java/com/google/api/generator/engine/ast/ExprStatement.java @@ -52,6 +52,7 @@ public ExprStatement build() { (expr instanceof MethodInvocationExpr) || (expr instanceof ReferenceConstructorExpr) || (expr instanceof AssignmentExpr) + || (expr instanceof AssignmentOperationExpr) || (expr instanceof ThrowExpr) || (expr instanceof ReturnExpr) || (expr instanceof UnaryOperationExpr diff --git a/src/test/java/com/google/api/generator/engine/ast/ExprStatementTest.java b/src/test/java/com/google/api/generator/engine/ast/ExprStatementTest.java index b43adb5a3d..d97a3ddce3 100644 --- a/src/test/java/com/google/api/generator/engine/ast/ExprStatementTest.java +++ b/src/test/java/com/google/api/generator/engine/ast/ExprStatementTest.java @@ -79,6 +79,15 @@ public void validExprStatement_unaryOperation() { Variable.builder().setType(TypeNode.INT).setName("i").build()))); } + @Test + public void validExprStatement_assignmentOperationExpr() { + VariableExpr lhsExpr = + VariableExpr.withVariable(Variable.builder().setName("i").setType(TypeNode.INT).build()); + ValueExpr rhsExpr = + ValueExpr.withValue(PrimitiveValue.builder().setValue("5").setType(TypeNode.INT).build()); + assertValidExprStatement(AssignmentOperationExpr.multiplyAssignmentWithExprs(lhsExpr, rhsExpr)); + } + @Test public void invalidExprStatement_variable() { Variable variable = Variable.builder().setType(TypeNode.INT).setName("libraryClient").build();