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

Commit fac81d7

Browse files
committed
SI-9206 De-perk the welcome message
The welcome message defaults to a sober header followed by one line of instructions.
1 parent 9124369 commit fac81d7

File tree

6 files changed

+68
-40
lines changed

6 files changed

+68
-40
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ 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!
22-
|%1$s (%3$s, Java %2$s).
21+
"""Welcome to Scala %1$#s (%3$s, Java %2$s).
2322
|Type in expressions for evaluation. Or try :help.""".stripMargin
2423
)
2524

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ abstract class ReplTest extends DirectTest {
3434
log("eval(): settings = " + s)
3535
val lines = ILoop.runForTranscript(code, s, inSession = inSession).lines
3636
(if (welcoming) {
37-
val welcome = Regex.quote(header.lines.next).r
38-
val version = "(.*version).*".r
39-
var inHead = false
37+
val welcome = "(Welcome to Scala).*".r
38+
//val welcome = Regex.quote(header.lines.next).r
39+
//val version = "(.*version).*".r // version on separate line?
40+
//var inHead = false
4041
lines map {
41-
case s @ welcome() => inHead = true ; s
42-
case version(s) if inHead => inHead = false ; s
43-
case s => s
42+
//case s @ welcome() => inHead = true ; s
43+
//case version(s) if inHead => inHead = false ; s
44+
case welcome(s) => s
45+
case s => s
4446
}
4547
} else {
4648
lines drop header.lines.size

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#partest java6
2-
Welcome to Scala!
3-
version
2+
Welcome to Scala
43
Type in expressions for evaluation. Or try :help.
54

65
scala> :javap -app MyApp$
@@ -17,8 +16,7 @@ public final void delayedEndpoint$MyApp$1();
1716

1817
scala> :quit
1918
#partest java7
20-
Welcome to Scala!
21-
version
19+
Welcome to Scala
2220
Type in expressions for evaluation. Or try :help.
2321

2422
scala> :javap -app MyApp$
@@ -39,8 +37,7 @@ scala> :javap -app MyApp$
3937

4038
scala> :quit
4139
#partest java8
42-
Welcome to Scala!
43-
version
40+
Welcome to Scala
4441
Type in expressions for evaluation. Or try :help.
4542

4643
scala> :javap -app MyApp$

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import scala.tools.partest.{ SessionTest, Welcoming }
44
// SI-7740
55
object Test extends SessionTest with Welcoming {
66
def session =
7-
"""Welcome to Scala!
8-
version
7+
"""Welcome to Scala
98
Type in expressions for evaluation. Or try :help.
109
1110
scala> def f = throw new Exception("Uh-oh")

test/files/run/t6502.scala

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import scala.tools.nsc.Settings
2-
import scala.tools.nsc.interpreter.ILoop
2+
import scala.tools.nsc.interpreter.{ ILoop, replProps }
33
import scala.tools.nsc.settings.ClassPathRepresentationType
44
import scala.tools.partest._
55

66
object Test extends StoreReporterDirectTest {
77
def code = ???
88

9+
lazy val headerLength = replProps.welcome.lines.size
10+
lazy val promptLength = replProps.prompt.lines.size - 1 // extra newlines
11+
912
def compileCode(code: String, jarFileName: String) = {
1013
val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
1114
compileString(newCompiler("-cp", classpath, "-d", s"${testOutput.path}/$jarFileName"))(code)
@@ -56,14 +59,21 @@ object Test extends StoreReporterDirectTest {
5659
val jar = "test1.jar"
5760
compileCode(app1, jar)
5861

59-
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "test.Test.test()")
62+
val codeToRun = s"""
63+
|:require ${testOutput.path}/$jar
64+
|test.Test.test()
65+
|""".stripMargin.trim
6066
val output = ILoop.run(codeToRun, settings)
61-
val lines = output.split("\n")
62-
assert {
63-
lines(4).contains("Added") && lines(4).contains("test1.jar")
64-
}
67+
var lines = output.lines.drop(headerLength)
68+
lines = lines drop promptLength
69+
val added = lines.next
70+
assert (
71+
added.contains("Added") && added.contains("test1.jar"),
72+
s"[${added}] in [${output.lines.mkString("/")}]"
73+
)
74+
lines = lines drop promptLength
6575
assert {
66-
lines(lines.length-3).contains("testing...")
76+
lines.next.contains("testing...")
6777
}
6878
}
6979

@@ -73,14 +83,21 @@ object Test extends StoreReporterDirectTest {
7383
val jar2 = "test2.jar"
7484
compileCode(app2, jar2)
7585

76-
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar2")
86+
val codeToRun = s"""
87+
|:require ${testOutput.path}/$jar1
88+
|:require ${testOutput.path}/$jar2
89+
|""".stripMargin.trim
7790
val output = ILoop.run(codeToRun, settings)
78-
val lines = output.split("\n")
91+
var lines = output.lines.drop(headerLength)
92+
lines = lines drop promptLength
93+
val added = lines.next
7994
assert {
80-
lines(4).contains("Added") && lines(4).contains("test1.jar")
95+
added.contains("Added") && added.contains("test1.jar")
8196
}
97+
lines = lines drop promptLength
98+
val msg = lines.next
8299
assert {
83-
lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict")
100+
msg.contains("test2.jar") && msg.contains("existing classpath entries conflict")
84101
}
85102
}
86103

@@ -90,28 +107,42 @@ object Test extends StoreReporterDirectTest {
90107
val jar3 = "test3.jar"
91108
compileCode(app3, jar3)
92109

93-
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar3", "test.Test3.test()")
110+
val codeToRun = s"""
111+
|:require ${testOutput.path}/$jar1
112+
|:require ${testOutput.path}/$jar3
113+
|test.Test3.test()
114+
|""".stripMargin.trim
94115
val output = ILoop.run(codeToRun, settings)
95-
val lines = output.split("\n")
116+
var lines = output.lines.drop(headerLength)
117+
lines = lines drop promptLength
118+
val added = lines.next
96119
assert {
97-
lines(4).contains("Added") && lines(4).contains("test1.jar")
120+
added.contains("Added") && added.contains("test1.jar")
98121
}
122+
lines = lines drop (2 * promptLength + 1)
99123
assert {
100-
lines(lines.length-3).contains("new object in existing package")
124+
lines.next.contains("new object in existing package")
101125
}
102126
}
103127

104128
def test4(): Unit = {
105129
// twice the same jar should be rejected
106130
val jar1 = "test1.jar"
107-
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar1")
131+
val codeToRun = s"""
132+
|:require ${testOutput.path}/$jar1
133+
|:require ${testOutput.path}/$jar1
134+
|""".stripMargin.trim
108135
val output = ILoop.run(codeToRun, settings)
109-
val lines = output.split("\n")
136+
var lines = output.lines.drop(headerLength)
137+
lines = lines drop promptLength
138+
val added = lines.next
110139
assert {
111-
lines(4).contains("Added") && lines(4).contains("test1.jar")
140+
added.contains("Added") && added.contains("test1.jar")
112141
}
142+
lines = lines drop promptLength
143+
val msg = lines.next
113144
assert {
114-
lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict")
145+
msg.contains("test1.jar") && msg.contains("existing classpath entries conflict")
115146
}
116147
}
117148

@@ -127,7 +158,10 @@ object Test extends StoreReporterDirectTest {
127158
// classloader to parse .class files in order to read their names.
128159
val jar = "test6.jar"
129160
compileCode(app6, jar)
130-
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "import test6._; new A; new Z")
161+
val codeToRun = s"""
162+
|:require ${testOutput.path}/$jar
163+
|import test6._; new A; new Z
164+
|""".stripMargin.trim
131165
val output = ILoop.run(codeToRun, settings)
132166
assert(output.contains("created test6.A"), output)
133167
assert(output.contains("created test6.Z"), output)
@@ -141,6 +175,4 @@ object Test extends StoreReporterDirectTest {
141175
test5()
142176
test6()
143177
}
144-
145-
def toCodeInSeparateLines(lines: String*): String = lines mkString "\n"
146178
}

test/files/run/t7805-repl-i.check

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Loading t7805-repl-i.script...
22
import util._
33

4-
Welcome to Scala!
5-
version
4+
Welcome to Scala
65
Type in expressions for evaluation. Or try :help.
76

87
scala> Console println Try(8)

0 commit comments

Comments
 (0)