CompletenessPrettyPrinter implements CompletenessVisitor { public String prettyprint(ASTCompletenessNode node) { getPrinter().clearBuffer(); node.accept(getRealThis()); return getPrinter().getContent(); } CompletenessPrettyPrinter(IndentPrinter printer); @Override void handle(ASTCompleteness node); IndentPrinter getPrinter(); String prettyprint(ASTCompletenessNode node); @Override void setRealThis(CompletenessVisitor realThis); @Override CompletenessVisitor getRealThis();  }
@Test public void testCompleteness() throws IOException { TestCompletenessParser parser = new TestCompletenessParser(); Optional<ASTCompleteness> result = parser.parseCompleteness(new StringReader("(c)")); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); ASTCompleteness completeness = result.get(); CompletenessPrettyPrinter prettyPrinter = new CompletenessPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(completeness); result = parser.parseCompleteness(new StringReader(output)); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); assertTrue(completeness.deepEquals(result.get())); }
@Test public void testIncompleteness() throws IOException { TestCompletenessParser parser = new TestCompletenessParser(); Optional<ASTCompleteness> result = parser.parseCompleteness(new StringReader("(...)")); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); ASTCompleteness completeness = result.get(); CompletenessPrettyPrinter prettyPrinter = new CompletenessPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(completeness); result = parser.parseCompleteness(new StringReader(output)); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); assertTrue(completeness.deepEquals(result.get())); }
@Test public void testRightCompleteness() throws IOException { TestCompletenessParser parser = new TestCompletenessParser(); Optional<ASTCompleteness> result = parser.parseCompleteness(new StringReader("(...,c)")); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); ASTCompleteness completeness = result.get(); CompletenessPrettyPrinter prettyPrinter = new CompletenessPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(completeness); result = parser.parseCompleteness(new StringReader(output)); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); assertTrue(completeness.deepEquals(result.get())); }
@Test public void testLeftCompleteness() throws IOException { TestCompletenessParser parser = new TestCompletenessParser(); Optional<ASTCompleteness> result = parser.parseCompleteness(new StringReader("(c,...)")); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); ASTCompleteness completeness = result.get(); CompletenessPrettyPrinter prettyPrinter = new CompletenessPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(completeness); result = parser.parseCompleteness(new StringReader(output)); assertFalse(parser.hasErrors()); assertTrue(result.isPresent()); assertTrue(completeness.deepEquals(result.get())); }