diff options
author | Som Snytt <som.snytt@gmail.com> | 2015-06-24 21:32:07 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2015-06-24 21:32:07 -0700 |
commit | 91243694982f10d6061edac562b9af32b7bc9f4f (patch) | |
tree | 2b651f9c4bc5e83ab93ed139b95336a6574cbc08 /src/partest-extras | |
parent | eab44dd09223974c7515a2413bc461ee3808d682 (diff) | |
download | scala-91243694982f10d6061edac562b9af32b7bc9f4f.tar.gz scala-91243694982f10d6061edac562b9af32b7bc9f4f.tar.bz2 scala-91243694982f10d6061edac562b9af32b7bc9f4f.zip |
SI-9206 Update REPL welcome message
Everyone knows that a `help` command will result in `more information`.
This commit moves the version string to the second line and adds some
verve to the welcome.
If anyone can't live without the old banner, they are now able to
configure it explicitly, so there is still no blood on our hands.
```
$ scala
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_40).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :quit
$ skala
Welcome to Scala!
version 2.11.7-20150623-155244-eab44dd092 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_40).
Type in expressions for evaluation. Or try :help.
scala> :quit
```
REPL tests now lop off the actual length of the welcome header; or, if
necessary, remove the version number from a header embedded in output.
Diffstat (limited to 'src/partest-extras')
-rw-r--r-- | src/partest-extras/scala/tools/partest/ReplTest.scala | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/partest-extras/scala/tools/partest/ReplTest.scala b/src/partest-extras/scala/tools/partest/ReplTest.scala index 1fde2370d3..756ae21b43 100644 --- a/src/partest-extras/scala/tools/partest/ReplTest.scala +++ b/src/partest-extras/scala/tools/partest/ReplTest.scala @@ -6,8 +6,9 @@ package scala.tools.partest import scala.tools.nsc.Settings -import scala.tools.nsc.interpreter.ILoop +import scala.tools.nsc.interpreter.{ ILoop, replProps } import java.lang.reflect.{ Method => JMethod, Field => JField } +import scala.util.matching.Regex import scala.util.matching.Regex.Match /** A class for testing repl code. @@ -19,30 +20,31 @@ abstract class ReplTest extends DirectTest { // final because we need to enforce the existence of a couple settings. final override def settings: Settings = { val s = super.settings - // s.Yreplsync.value = true s.Xnojline.value = true transformSettings(s) } + def normalize(s: String) = s /** True for SessionTest to preserve session text. */ def inSession: Boolean = false - /** True to preserve welcome text. */ + /** True to preserve welcome header, eliding version number. */ def welcoming: Boolean = false - lazy val welcome = "(Welcome to Scala) version .*".r - def normalize(s: String) = s match { - case welcome(w) => w - case s => s - } - def unwelcoming(s: String) = s match { - case welcome(w) => false - case _ => true - } + lazy val header = replProps.welcome def eval() = { val s = settings log("eval(): settings = " + s) - //ILoop.runForTranscript(code, s).lines drop 1 // not always first line val lines = ILoop.runForTranscript(code, s, inSession = inSession).lines - if (welcoming) lines map normalize - else lines filter unwelcoming + (if (welcoming) { + val welcome = Regex.quote(header.lines.next).r + val version = "(.*version).*".r + var inHead = false + lines map { + case s @ welcome() => inHead = true ; s + case version(s) if inHead => inHead = false ; s + case s => s + } + } else { + lines drop header.lines.size + }) map normalize } def show() = eval() foreach println } |