Skip to content

Commit a17abba

Browse files
author
Som Snytt
committed
Tweak repl & test
1 parent 2467132 commit a17abba

File tree

4 files changed

+22
-61
lines changed

4 files changed

+22
-61
lines changed

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,14 @@ class IMain(val settings: Settings, parentClassLoaderOverride: Option[ClassLoade
621621
override lazy val power = new Power(this, new StdReplVals(this))(tagOfStdReplVals, classTag[StdReplVals])
622622

623623
/** Here is where we:
624-
*
625-
* 1) Read some source code, and put it in the "read" object.
626-
* 2) Evaluate the read object, and put the result in the "eval" object.
627-
* 3) Create a String for human consumption, and put it in the "print" object.
628-
*
629-
* Read! Eval! Print! Some of that not yet centralized here.
630-
*/
631-
class ReadEvalPrint(val lineId: Int) {
632-
def this() = this(freshLineId())
633-
624+
*
625+
* 1) Read some source code, and put it in the "read" object.
626+
* 2) Evaluate the read object, and put the result in the "eval" object.
627+
* 3) Create a String for human consumption, and put it in the "print" object.
628+
*
629+
* Read! Eval! Print! Some of that not yet centralized here.
630+
*/
631+
class ReadEvalPrint(val lineId: Int = freshLineId()) {
634632
val packageName = sessionNames.packageName(lineId)
635633
val readName = sessionNames.read
636634
val evalName = sessionNames.eval
@@ -824,7 +822,7 @@ class IMain(val settings: Settings, parentClassLoaderOverride: Option[ClassLoade
824822
}
825823

826824
/** handlers for each tree in this request */
827-
val handlers: List[MemberHandler] = trees map (memberHandlers chooseHandler _)
825+
val handlers: List[MemberHandler] = trees.map(memberHandlers.chooseHandler(_))
828826
val definesValueClass = handlers.exists(_.definesValueClass)
829827

830828
val isClassBased = IMain.this.isClassBased && !definesValueClass
@@ -968,7 +966,8 @@ class IMain(val settings: Settings, parentClassLoaderOverride: Option[ClassLoade
968966

969967

970968
/** Compile the object file. Returns whether the compilation succeeded.
971-
* If all goes well, the "types" map is computed. */
969+
* If all goes well, the "types" map is computed.
970+
*/
972971
def compile: Boolean = {
973972

974973
// compile the object containing the user's code

test/files/run/repl-assign.check

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11

2-
scala> var x = 10
3-
var x: Int = 10
2+
scala> var x = 42
3+
var x: Int = 42
44

5-
scala> var y = 11
6-
var y: Int = 11
7-
8-
scala> x = 12
5+
scala> x = 17
96
// mutated x
107

11-
scala> y = 13
12-
// mutated y
13-
14-
scala> x += 30
8+
scala> x += 10
159
// mutated x
1610

11+
scala> x
12+
val res0: Int = 27
13+
1714
scala> :quit

test/files/run/repl-assign.scala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import scala.tools.partest.ReplTest
21

3-
object Test extends ReplTest {
4-
def code = """
5-
var x = 10
6-
var y = 11
7-
x = 12
8-
y = 13
9-
x += 30
10-
"""
11-
}
2+
import scala.tools.partest.SessionTest
3+
4+
object Test extends SessionTest

test/files/run/t8935-object.scala

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

3-
import scala.tools.nsc.Settings
4-
5-
object Test extends SessionTest {
6-
/* future
7-
override def transformSettings(s: Settings): Settings = {
8-
//s.YreplWrap.value = "object"
9-
s
10-
}
11-
*/
12-
override def session =
13-
"""
14-
scala> 41+1
15-
res0: Int = 42
16-
17-
scala> $intp.valueOfTerm($intp.mostRecentVar)
18-
res1: Option[Any] = Some(42)
19-
20-
scala> val i = 17 ; 64
21-
i: Int = 17
22-
res2: Int = 64
23-
24-
scala> $intp.valueOfTerm($intp.mostRecentVar)
25-
res3: Option[Any] = Some(64)
26-
27-
scala> $intp.valueOfTerm("i")
28-
res4: Option[Any] = Some(17)
29-
30-
scala> :quit"""
31-
}
3+
object Test extends SessionTest

0 commit comments

Comments
 (0)