### Question:
TreePrinter { public static String table(Tree tree) { Table table = new Table("AST node class", "first…last tokens", "line:col"); addAstNode(table, tree, 0); return table.toString(); } private  TreePrinter(); static String tree2string(List<Tree> trees); static String tree2string(Tree tree); static String table(Tree tree); static String kind(Tree node);  }### Answer:
@Test public void table_test() { Tree add = binary(BinaryExpressionTree.Operator.PLUS, identifier("x", new TextRangeImpl(1,42,1,43),"x"), integerLiteral("1", new TextRangeImpl(1,44,1,45), "1"), new TextRangeImpl(1,42,1,45), "x", "1"); Tree assign = assignment(identifier("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", new TextRangeImpl(1,8,1,39), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), add, new TextRangeImpl(1,8,1,45),"x", "=", "x", "1"); String actual = TreePrinter.table(assign); TreePrinter.Table expected = new TreePrinter.Table("AST node class", "first…last tokens", "line:col"); expected.add("AssignmentExpressionTree {","x … 1","1:9 … 1:46"); expected.add(" IdentifierTree","xxxxxxxxxxx…xxxxxxxxxxx","1:9 … 1:40"); expected.add(" BinaryExpressionTree {","x … 1","1:43 … 1:46"); expected.add(" IdentifierTree","x","1:43 … 1:44"); expected.add(" IntegerLiteralTree","1","1:45 … 1:46"); expected.add(" }","",""); expected.add("}","",""); assertEquals(expected.toString(), actual); }