diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/interpreter.scala | 42 | ||||
-rw-r--r-- | test/files/run/bug3376.check | 13 | ||||
-rw-r--r-- | test/files/run/bug3376.scala | 16 |
3 files changed, 36 insertions, 35 deletions
diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala index 2c2756828b..70ad900305 100644 --- a/test/files/jvm/interpreter.scala +++ b/test/files/jvm/interpreter.scala @@ -2,6 +2,8 @@ import scala.tools.nsc._ import java.io.{BufferedReader, StringReader, PrintWriter, Writer, OutputStreamWriter} +import interpreter.ILoop + object Test { val testCodeString = <code> // basics @@ -144,43 +146,13 @@ def f(e: Exp) = e match {{ // non-exhaustive warning here </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 : Array[Char] = 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 output = new PrintWriter( - new Skip1Writer(new OutputStreamWriter(Console.out))) - val repl = new InterpreterLoop(input, output) - val settings = new Settings - // when running that compiler, give it a scala-library to the classpath - settings.classpath.value = System.getProperty("java.class.path") - repl.main(settings) - println() + // This drops the first line of output because the repl + // prints a version number. + (ILoop run testCodeString).lines drop 1 foreach println + val settings = new Settings + settings.classpath.value = sys.props("java.class.path") val interp = new Interpreter(settings) interp.interpret("def plusOne(x: Int) = x + 1") interp.interpret("plusOne(5)") diff --git a/test/files/run/bug3376.check b/test/files/run/bug3376.check new file mode 100644 index 0000000000..7286096022 --- /dev/null +++ b/test/files/run/bug3376.check @@ -0,0 +1,13 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> +scala> defined class M + +scala> m1: M[Int] = mmm + +scala> m2: M[Float] = mmm + +scala> m3: M[String] = mmm + +scala> diff --git a/test/files/run/bug3376.scala b/test/files/run/bug3376.scala new file mode 100644 index 0000000000..5cff50185c --- /dev/null +++ b/test/files/run/bug3376.scala @@ -0,0 +1,16 @@ +import scala.tools.nsc.interpreter._ + +object Test { + class M[@specialized T] { } + + val code = """ + |class M[@specialized T] { override def toString = "mmm" } + |val m1 = new M[Int]() + |val m2 = new M[Float]() + |val m3 = new M[String]() + |""".stripMargin + + def main(args: Array[String]): Unit = { + (ILoop run code).lines drop 1 foreach println + } +} |