Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit 9124369

Browse files
committed
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.
1 parent eab44dd commit 9124369

File tree

86 files changed

+61
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+61
-219
lines changed

src/compiler/scala/tools/nsc/Properties.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ object Properties extends scala.util.PropertiesTrait {
1818
def residentPromptString = scalaPropOrElse("resident.prompt", "\nnsc> ")
1919
def shellPromptString = scalaPropOrElse("shell.prompt", "%nscala> ")
2020
def shellWelcomeString = scalaPropOrElse("shell.welcome",
21-
"""Welcome to Scala %1$s (%3$s, Java %2$s).
22-
|Type in expressions to have them evaluated.
23-
|Type :help for more information.""".stripMargin
21+
"""Welcome to Scala!
22+
|%1$s (%3$s, Java %2$s).
23+
|Type in expressions for evaluation. Or try :help.""".stripMargin
2424
)
2525

2626
// message to display at EOF (which by default ends with

src/partest-extras/scala/tools/partest/ReplTest.scala

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
package scala.tools.partest
77

88
import scala.tools.nsc.Settings
9-
import scala.tools.nsc.interpreter.ILoop
9+
import scala.tools.nsc.interpreter.{ ILoop, replProps }
1010
import java.lang.reflect.{ Method => JMethod, Field => JField }
11+
import scala.util.matching.Regex
1112
import scala.util.matching.Regex.Match
1213

1314
/** A class for testing repl code.
@@ -19,30 +20,31 @@ abstract class ReplTest extends DirectTest {
1920
// final because we need to enforce the existence of a couple settings.
2021
final override def settings: Settings = {
2122
val s = super.settings
22-
// s.Yreplsync.value = true
2323
s.Xnojline.value = true
2424
transformSettings(s)
2525
}
26+
def normalize(s: String) = s
2627
/** True for SessionTest to preserve session text. */
2728
def inSession: Boolean = false
28-
/** True to preserve welcome text. */
29+
/** True to preserve welcome header, eliding version number. */
2930
def welcoming: Boolean = false
30-
lazy val welcome = "(Welcome to Scala) version .*".r
31-
def normalize(s: String) = s match {
32-
case welcome(w) => w
33-
case s => s
34-
}
35-
def unwelcoming(s: String) = s match {
36-
case welcome(w) => false
37-
case _ => true
38-
}
31+
lazy val header = replProps.welcome
3932
def eval() = {
4033
val s = settings
4134
log("eval(): settings = " + s)
42-
//ILoop.runForTranscript(code, s).lines drop 1 // not always first line
4335
val lines = ILoop.runForTranscript(code, s, inSession = inSession).lines
44-
if (welcoming) lines map normalize
45-
else lines filter unwelcoming
36+
(if (welcoming) {
37+
val welcome = Regex.quote(header.lines.next).r
38+
val version = "(.*version).*".r
39+
var inHead = false
40+
lines map {
41+
case s @ welcome() => inHead = true ; s
42+
case version(s) if inHead => inHead = false ; s
43+
case s => s
44+
}
45+
} else {
46+
lines drop header.lines.size
47+
}) map normalize
4648
}
4749
def show() = eval() foreach println
4850
}

src/repl/scala/tools/nsc/interpreter/ReplProps.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ReplProps {
4444
}
4545

4646
// Handy system prop for shell prompt, or else pick it up from compiler.properties
47-
val promptString = Prop[String]("scala.repl.prompt").option getOrElse (if (info) "%nscala %s> " else shellPromptString)
47+
val promptString = Prop[String]("scala.repl.prompt").option getOrElse (if (info) "%nscala %#s> " else shellPromptString)
4848
val promptText = enversion(promptString)
4949
val prompt = encolor(promptText)
5050

@@ -57,10 +57,11 @@ class ReplProps {
5757
}
5858
val continuePrompt = encolor(continueText)
5959

60+
// Next time.
6061
//def welcome = enversion(Prop[String]("scala.repl.welcome") or shellWelcomeString)
6162
def welcome = enversion {
6263
val p = Prop[String]("scala.repl.welcome")
63-
if (p.isSet) p.value else shellWelcomeString
64+
if (p.isSet) p.get else shellWelcomeString
6465
}
6566

6667
/** CSV of paged,across to enable pagination or `-x` style

test/files/jvm/interpreter.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> // basics
53

test/files/jvm/throws-annot-from-java.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> :power
53
** Power User mode enabled - BEEP WHIR GYVE **

test/files/jvm/xml05.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> <city name="San Jos&eacute;"/>
53
res0: scala.xml.Elem = <city name="San Jos&eacute;"/>

test/files/run/class-symbol-contravariant.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> :power
53
** Power User mode enabled - BEEP WHIR GYVE **

test/files/run/constant-type.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> :power
53
** Power User mode enabled - BEEP WHIR GYVE **

test/files/run/constrained-types.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> class Annot(obj: Any) extends annotation.Annotation with annotation.TypeConstraint
53
defined class Annot

test/files/run/kind-repl-command.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> :kind scala.Option
53
scala.Option's kind is F[+A]

test/files/run/lub-visibility.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> // should infer List[scala.collection.immutable.Seq[Nothing]]
53

test/files/run/macro-bundle-repl.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import scala.language.experimental.macros
53
import scala.language.experimental.macros

test/files/run/macro-repl-basic.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import language.experimental.macros
53
import language.experimental.macros

test/files/run/macro-repl-dontexpand.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> def bar1(c: scala.reflect.macros.blackbox.Context) = ???
53
bar1: (c: scala.reflect.macros.blackbox.Context)Nothing

test/files/run/macro-system-properties.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import scala.language.experimental._, scala.reflect.macros.blackbox.Context
53
import scala.language.experimental._

test/files/run/reflection-equality.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> class X {
53
def methodIntIntInt(x: Int, y: Int) = x+y

test/files/run/reflection-magicsymbols-repl.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import scala.reflect.runtime.universe._
53
import scala.reflect.runtime.universe._

test/files/run/reflection-repl-classes.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> class A
53
defined class A

test/files/run/reflection-repl-elementary.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> scala.reflect.runtime.universe.typeOf[List[Nothing]]
53
res0: reflect.runtime.universe.Type = scala.List[Nothing]

test/files/run/reify-repl-fail-gracefully.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import language.experimental.macros
53
import language.experimental.macros

test/files/run/reify_newimpl_22.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import scala.reflect.runtime.universe._
53
import scala.reflect.runtime.universe._

test/files/run/reify_newimpl_23.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import scala.reflect.runtime.universe._
53
import scala.reflect.runtime.universe._

test/files/run/reify_newimpl_25.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> {
53
import scala.reflect.runtime.universe._

test/files/run/reify_newimpl_26.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> def foo[T]{
53
import scala.reflect.runtime.universe._

test/files/run/reify_newimpl_35.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import scala.reflect.runtime.universe._
53
import scala.reflect.runtime.universe._

test/files/run/repl-assign.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> var x = 10
53
x: Int = 10

test/files/run/repl-bare-expr.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> 2 ; 3
53
<console>:10: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses

test/files/run/repl-colon-type.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> :type List[1, 2, 3]
53
<console>:1: error: identifier expected but integer literal found.

test/files/run/repl-empty-package.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> println(Bippy.bippy)
53
bippy!

test/files/run/repl-javap-app.check

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#partest java6
2-
Welcome to Scala
3-
Type in expressions to have them evaluated.
4-
Type :help for more information.
2+
Welcome to Scala!
3+
version
4+
Type in expressions for evaluation. Or try :help.
55

66
scala> :javap -app MyApp$
77
public final void delayedEndpoint$MyApp$1();
@@ -17,9 +17,9 @@ public final void delayedEndpoint$MyApp$1();
1717

1818
scala> :quit
1919
#partest java7
20-
Welcome to Scala
21-
Type in expressions to have them evaluated.
22-
Type :help for more information.
20+
Welcome to Scala!
21+
version
22+
Type in expressions for evaluation. Or try :help.
2323

2424
scala> :javap -app MyApp$
2525
public final void delayedEndpoint$MyApp$1();
@@ -39,9 +39,9 @@ scala> :javap -app MyApp$
3939

4040
scala> :quit
4141
#partest java8
42-
Welcome to Scala
43-
Type in expressions to have them evaluated.
44-
Type :help for more information.
42+
Welcome to Scala!
43+
version
44+
Type in expressions for evaluation. Or try :help.
4545

4646
scala> :javap -app MyApp$
4747
public final void delayedEndpoint$MyApp$1();

test/files/run/repl-out-dir.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> case class Bippy(x: Int)
53
defined class Bippy

test/files/run/repl-parens.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> (2)
53
res0: Int = 2

test/files/run/repl-paste-2.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> scala> 999l
53

test/files/run/repl-paste-3.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> println(3)
53
3

test/files/run/repl-paste-4.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import scala.tools.partest.SessionTest
33

44
object Test extends SessionTest {
55
def session =
6-
s"""|Type in expressions to have them evaluated.
7-
|Type :help for more information.
8-
|
6+
s"""|
97
|scala> :paste $pastie
108
|Pasting file $pastie...
119
|defined class Foo

test/files/run/repl-paste-raw.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import scala.tools.partest.SessionTest
33

44
object Test extends SessionTest {
55
def session =
6-
s"""|Type in expressions to have them evaluated.
7-
|Type :help for more information.
8-
|
6+
s"""|
97
|scala> :paste -raw $pastie
108
|Pasting file $pastie...
119
|

test/files/run/repl-paste.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> :paste
53
// Entering paste mode (ctrl-D to finish)

test/files/run/repl-power.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> :power
53
** Power User mode enabled - BEEP WHIR GYVE **

test/files/run/repl-reset.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> val x1 = 1
53
x1: Int = 1

test/files/run/repl-save.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import scala.tools.partest.SessionTest
22

33
object Test extends SessionTest {
44
def session =
5-
s"""|Type in expressions to have them evaluated.
6-
|Type :help for more information.
7-
|
5+
s"""|
86
|scala> val i = 7
97
|i: Int = 7
108
|

test/files/run/repl-term-macros.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> import scala.reflect.macros.blackbox.Context
53
import scala.reflect.macros.blackbox.Context

test/files/run/repl-transcript.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> scala> class Bippity
53

test/files/run/repl-trim-stack-trace.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import scala.tools.partest.{ SessionTest, Welcoming }
44
// SI-7740
55
object Test extends SessionTest with Welcoming {
66
def session =
7-
"""Welcome to Scala
8-
Type in expressions to have them evaluated.
9-
Type :help for more information.
7+
"""Welcome to Scala!
8+
version
9+
Type in expressions for evaluation. Or try :help.
1010
1111
scala> def f = throw new Exception("Uh-oh")
1212
f: Nothing
@@ -37,7 +37,6 @@ scala> :quit"""
3737
// normalize the "elided" lines because the frame count depends on test context
3838
lazy val elided = """(\s+\.{3} )\d+( elided)""".r
3939
override def normalize(line: String) = line match {
40-
case welcome(w) => w
4140
case elided(ellipsis, suffix) => s"$ellipsis???$suffix"
4241
case s => s
4342
}

test/files/run/repl-type-verbose.check

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Type in expressions to have them evaluated.
2-
Type :help for more information.
31

42
scala> // verbose!
53

0 commit comments

Comments
 (0)