### Question:
Code extends ArrayList<String> { public void add(InputStream contents) { for (String line : IO.linesOf(contents)) { add(line); } } Code();  Code(Syntax syntax);  Code(int len, Syntax syntax); void add(InputStream contents); void add(String format, Object... args); @Override boolean add(String text); String text(); @Override String toString(); void writeTo(File file);  }### Answer:
@Test public void addsLines() { String line1 = RANDOM.string(); String line2 = RANDOM.string(); code.add(line1); code.add(line2); assertEquals("Lines", Arrays.asList(line1, line2), code); }
@Test public void addsFormattedLines() { String arg1 = RANDOM.string(); int arg2 = RANDOM.integer(); String format = "%s_%d"; code.add(format, arg1, arg2); assertEquals("Lines", Arrays.asList(String.format(format, arg1, arg2)), code); }
@Test public void isEqualWhenSameText() { String line1 = RANDOM.string(); String line2 = RANDOM.string(); code.add(line1); code.add(line2); Code other = new Code(); for (String line : code) { other.add(line); } assertEquals("Equals when same text", code, other); }