diff options
author | Lex Spoon <lex@lexspoon.org> | 2007-06-19 16:14:43 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2007-06-19 16:14:43 +0000 |
commit | 627257dfbb281b8e32a9aafd006703ff4fa3854c (patch) | |
tree | 5c5a07b030fd60321792f7fbca73e464ffc8490c /test/files/run | |
parent | 542c248d614ab137b5d79c6a67bb98f147322a3f (diff) | |
download | scala-627257dfbb281b8e32a9aafd006703ff4fa3854c.tar.gz scala-627257dfbb281b8e32a9aafd006703ff4fa3854c.tar.bz2 scala-627257dfbb281b8e32a9aafd006703ff4fa3854c.zip |
Skip the first line of output, because now it i...
Skip the first line of output, because now it includes a version number
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/interpreter.check | 1 | ||||
-rw-r--r-- | test/files/run/interpreter.scala | 33 |
2 files changed, 31 insertions, 3 deletions
diff --git a/test/files/run/interpreter.check b/test/files/run/interpreter.check index 90745ee56f..5e56f05cf2 100644 --- a/test/files/run/interpreter.check +++ b/test/files/run/interpreter.check @@ -1,4 +1,3 @@ -This is a Scala shell. Type in expressions to have them evaluated. Type :help for more information. diff --git a/test/files/run/interpreter.scala b/test/files/run/interpreter.scala index c59ce9f758..34058b323a 100644 --- a/test/files/run/interpreter.scala +++ b/test/files/run/interpreter.scala @@ -1,5 +1,6 @@ import scala.tools.nsc._ -import java.io.{BufferedReader, StringReader, PrintWriter} +import java.io.{BufferedReader, StringReader, PrintWriter, + Writer, OutputStreamWriter} object Test { val testCodeString = <code> @@ -85,9 +86,37 @@ def x => y => z </code>.text + /** A writer that skips the first line of text. The first + * line of interpreter output is skipped because it includes + * a version number. */ + class Skip1Writer(writer: Writer) extends Writer { + var seenNL = false + + def write(cbuf: Array[Char], off: Int, len: Int) { + if (seenNL) + writer.write(cbuf, off, len) + else { + val slice = cbuf.slice(off, off+len) + val i = slice.indexOf('\n') + if (i >= 0) { + seenNL = true + writer.write(slice, i+1, slice.length-(i+1)) + } else { + // skip it + } + } + } + + def close() { writer.close() } + def flush() { writer.flush() } + } + + def main(args: Array[String]) { val input = new BufferedReader(new StringReader(testCodeString)) - val repl = new InterpreterLoop(input, new PrintWriter(Console.out)) + val output = new PrintWriter( + new Skip1Writer(new OutputStreamWriter(Console.out))) + val repl = new InterpreterLoop(input, output) repl.main(new Settings) println() } |