AssignmentExpressionsPrettyPrinter extends ExpressionsBasisPrettyPrinter implements AssignmentExpressionsVisitor { public String prettyprint(ASTExpression node) { getPrinter().clearBuffer(); node.accept(getRealThis()); return getPrinter().getContent(); } AssignmentExpressionsPrettyPrinter(IndentPrinter printer); @Override void handle(ASTIncSuffixExpression node); @Override void handle(ASTDecSuffixExpression node); @Override void handle(ASTIncPrefixExpression node); @Override void handle(ASTDecPrefixExpression node); @Override void handle(ASTAssignmentExpression node); IndentPrinter getPrinter(); String prettyprint(ASTExpression node); @Override void setRealThis(AssignmentExpressionsVisitor realThis); @Override AssignmentExpressionsVisitor getRealThis();  }
@Test public void testIncPrefixExpression() throws IOException { Optional<ASTIncPrefixExpression> result = parser.parse_StringIncPrefixExpression("++a"); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); ASTIncPrefixExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringIncPrefixExpression(output); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); assertTrue(ast.deepEquals(result.get())); }
@Test public void testDecPrefixExpression() throws IOException { Optional<ASTDecPrefixExpression> result = parser.parse_StringDecPrefixExpression("--a"); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); ASTDecPrefixExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringDecPrefixExpression(output); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); assertTrue(ast.deepEquals(result.get())); }
@Test public void testIncSuffixExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); ASTIncSuffixExpression result = AssignmentExpressionsMill.incSuffixExpressionBuilder() .setExpression(a.get()) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a++", output); }
@Test public void testDecSuffixExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); ASTDecSuffixExpression result = AssignmentExpressionsMill.decSuffixExpressionBuilder() .setExpression(a.get()) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a--", output); }
@Test public void testRegularAssignmentEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(EQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a=b", output); }
@Test public void testRegularAssignmentPlusEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(PLUSEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a+=b", output); }
@Test public void testRegularAssignmentMinusExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(MINUSEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a-=b", output); }
@Test public void testRegularAssignmentPercentEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(PERCENTEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a%=b", output); }
@Test public void testRegularAssignmentAndEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(ANDEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a&=b", output); }
@Test public void testRegularAssignmentRoofEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(ROOFEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a^=b", output); }
@Test public void testRegularAssignmentSlashEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(SLASHEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a/=b", output); }
@Test public void testRegularAssignmentStarEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(STAREQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a*=b", output); }
@Test public void testRegularAssignmentPipeEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(PIPEEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a|=b", output); }
@Test public void testRegularAssignmentLTLTEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(LTLTEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a<<=b", output); }
@Test public void testRegularAssignmentGTGTEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(GTGTEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a>>=b", output); }
@Test public void testRegularAssignmentGTGTGTEqualsExpression() throws IOException { Optional<ASTExpression> a = parser.parse_StringExpression("a"); Optional<ASTExpression> b = parser.parse_StringExpression("b"); assertFalse(parser.hasErrors()); assertTrue(a.isPresent()); assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) .setOperator(GTGTGTEQUALS) .build(); String output = prettyPrinter.prettyprint(result); assertEquals("a>>>=b", output); }