CodeOutput extends CodeChunk implements CodeBlock { @Override public CodeBlock block() { return insert(new CodeOutput(env, this.indent.toString(), this.buffer)); } CodeOutput(); protected  CodeOutput(Env env, String indent, StringBuilder buffer); String toDumpString(); @Override Writer getWriter(); @Override void indent(); @Override void dedent(); @Override void print(String pattern, Object... args); @Override void println(String pattern, Object... args); @Override CodeBlock block(); CodeOutput add(CodeRenderable renderable); @Override String gensym(); String toString(); @Override void append(CharSequence csq);  }
@Test public void testBlock() { CodeOutput output = new CodeOutput(); output.println("a"); output.indent(); output.println("b"); CodeBlock block = output.block(); output.dedent(); output.println("c"); block.println("{"); block.indent(); block.println("a2"); CodeBlock more = block.block(); block.println("a3"); block.dedent(); block.println("}"); more.println("d1"); Assert.assertEquals(output.toString(), "a\n b\n {\n a2\n d1\n a3\n }\nc\n"); }