@@ -11,38 +11,20 @@ import org.junit.Assert.fail
1111import dotc .reporting .diagnostic .MessageContainer
1212import results .Result
1313
14- sealed class NullPrintStream extends ByteArrayOutputStream {
15- override def write (b : Int ) = ()
16- override def write (b : Array [Byte ], off : Int , len : Int ) = ()
17- override def writeTo (out : OutputStream ) = ()
18- }
19-
20- sealed class StoringPrintStream extends PrintStream (new NullPrintStream ) {
21- private [this ] var sb = new StringBuilder
22-
23- override def println (obj : Object ) =
24- println(obj.toString)
25-
26- override def println (str : String ) = {
27- sb.append(str)
28- sb += '\n '
29- }
3014
31- def flushStored (): String = {
32- val str = sb.toString
33- sb = new StringBuilder
34- str
35- }
36- }
37-
38- class ReplTest extends ReplDriver (
15+ class ReplTest private (out : ByteArrayOutputStream ) extends ReplDriver (
3916 Array (" -classpath" , List (Jars .dottyLib, Jars .dottyInterfaces).mkString(" :" ), " -color:never" ),
40- new StoringPrintStream
17+ new PrintStream (out)
4118) with MessageRendering {
4219
43- /** Get the stored output from `out`, resetting the `StoringPrintStream` */
44- def storedOutput (): String =
45- stripColor(out.asInstanceOf [StoringPrintStream ].flushStored())
20+ def this () = this (new ByteArrayOutputStream )
21+
22+ /** Get the stored output from `out`, resetting the buffer */
23+ def storedOutput (): String = {
24+ val output = stripColor(out.toString)
25+ out.reset()
26+ output
27+ }
4628
4729 protected implicit def toParsed (expr : String )(implicit state : State ): Parsed = {
4830 implicit val ctx = state.run.runContext
0 commit comments