diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-03 19:52:51 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-03 19:52:51 +0000 |
commit | d858fc14ad79b9c8bbe066aec70ded8fa62b0275 (patch) | |
tree | 2dad390100ee9025b0f5445af6ba032dddb0fee5 | |
parent | 835be39b534accb0d341d0629662f5685ae2cfef (diff) | |
download | scala-d858fc14ad79b9c8bbe066aec70ded8fa62b0275.tar.gz scala-d858fc14ad79b9c8bbe066aec70ded8fa62b0275.tar.bz2 scala-d858fc14ad79b9c8bbe066aec70ded8fa62b0275.zip |
Logic bug in repl :paste parsing, no review.
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/IMain.scala | 2 | ||||
-rw-r--r-- | test/files/run/repl-paste-3.check | 14 | ||||
-rw-r--r-- | test/files/run/repl-paste-3.scala | 8 | ||||
-rw-r--r-- | test/files/run/repl-paste.check | 22 | ||||
-rw-r--r-- | test/files/run/repl-paste.scala | 20 |
5 files changed, 44 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 47e1aa49bb..467805fe36 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -470,7 +470,7 @@ class IMain(val settings: Settings, protected val out: JPrintWriter) extends Imp // Oh boy, the parser throws away parens so "(2+2)" is mispositioned. // So until we can fix the parser we'll have to go trawling. val adjustment = ((content take lastpos0).reverse takeWhile { ch => - ch.isWhitespace || ch == '(' || ch == ')' + ch.isWhitespace || ch == '(' }).length val lastpos = lastpos0 - adjustment diff --git a/test/files/run/repl-paste-3.check b/test/files/run/repl-paste-3.check new file mode 100644 index 0000000000..2b4c941c33 --- /dev/null +++ b/test/files/run/repl-paste-3.check @@ -0,0 +1,14 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> println(3) +3 + +scala> List(1,2) +res1: List[Int] = List(1, 2) + +scala> + +scala> diff --git a/test/files/run/repl-paste-3.scala b/test/files/run/repl-paste-3.scala new file mode 100644 index 0000000000..3f26799ccb --- /dev/null +++ b/test/files/run/repl-paste-3.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +println(3) + List(1,2) + """ +}
\ No newline at end of file diff --git a/test/files/run/repl-paste.check b/test/files/run/repl-paste.check index 50589433cd..d3e171fbfb 100644 --- a/test/files/run/repl-paste.check +++ b/test/files/run/repl-paste.check @@ -5,17 +5,17 @@ scala> :paste // Entering paste mode (ctrl-D to finish) - class Dingus - { - private val x = 5 - def y = Dingus.x * 2 - } - object Dingus - { - private val x = 55 - } - - val x = (new Dingus).y +class Dingus +{ + private val x = 5 + def y = Dingus.x * 2 +} +object Dingus +{ + private val x = 55 +} + +val x = (new Dingus).y // Exiting paste mode, now interpreting. diff --git a/test/files/run/repl-paste.scala b/test/files/run/repl-paste.scala index e2ebab1e45..5495505353 100644 --- a/test/files/run/repl-paste.scala +++ b/test/files/run/repl-paste.scala @@ -3,17 +3,17 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = ":paste\n" + ( """ - class Dingus - { - private val x = 5 - def y = Dingus.x * 2 - } - object Dingus - { - private val x = 55 - } +class Dingus +{ + private val x = 5 + def y = Dingus.x * 2 +} +object Dingus +{ + private val x = 55 +} - val x = (new Dingus).y +val x = (new Dingus).y """ ) }
\ No newline at end of file |