diff options
author | Raphael Jolly <rjolly@users.sourceforge.net> | 2014-01-30 13:29:02 +0100 |
---|---|---|
committer | Raphael Jolly <rjolly@users.sourceforge.net> | 2014-01-31 10:06:36 +0100 |
commit | 9dfac45e808017982e04fb20567c70b76dee3ede (patch) | |
tree | 4be4bf4202d87973b8f852e7c45a811720ff5923 /test/files/run | |
parent | 8f6f4032b5c026fd9301cebe28dde5bb7c8e264c (diff) | |
download | scala-9dfac45e808017982e04fb20567c70b76dee3ede.tar.gz scala-9dfac45e808017982e04fb20567c70b76dee3ede.tar.bz2 scala-9dfac45e808017982e04fb20567c70b76dee3ede.zip |
SI-7933 REPL javax.script eval is cached result
The problem is that the repl underneath the script engine evaluates input to
val res0..resN, so it is a one shot operation. To allow repetition,
compile(script) now returns a CompiledScript object whose eval method can be
called any number of times.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/t7843-jsr223-service.check | 2 | ||||
-rw-r--r-- | test/files/run/t7843-jsr223-service.scala | 8 | ||||
-rw-r--r-- | test/files/run/t7933.check | 2 | ||||
-rw-r--r-- | test/files/run/t7933.scala | 11 |
4 files changed, 23 insertions, 0 deletions
diff --git a/test/files/run/t7843-jsr223-service.check b/test/files/run/t7843-jsr223-service.check new file mode 100644 index 0000000000..a668df3567 --- /dev/null +++ b/test/files/run/t7843-jsr223-service.check @@ -0,0 +1,2 @@ +n: Object = 10 +12345678910 diff --git a/test/files/run/t7843-jsr223-service.scala b/test/files/run/t7843-jsr223-service.scala new file mode 100644 index 0000000000..31112212ea --- /dev/null +++ b/test/files/run/t7843-jsr223-service.scala @@ -0,0 +1,8 @@ +import scala.tools.nsc.interpreter.IMain + +object Test extends App { + val engine = new IMain.Factory getScriptEngine() + engine.asInstanceOf[IMain].settings.usejavacp.value = true + engine put ("n", 10) + engine eval "1 to n.asInstanceOf[Int] foreach print" +} diff --git a/test/files/run/t7933.check b/test/files/run/t7933.check new file mode 100644 index 0000000000..317e9677c3 --- /dev/null +++ b/test/files/run/t7933.check @@ -0,0 +1,2 @@ +hello +hello diff --git a/test/files/run/t7933.scala b/test/files/run/t7933.scala new file mode 100644 index 0000000000..b06dffcd80 --- /dev/null +++ b/test/files/run/t7933.scala @@ -0,0 +1,11 @@ +import scala.tools.nsc.interpreter.IMain + +object Test extends App { + val engine = new IMain.Factory getScriptEngine() + engine.asInstanceOf[IMain].settings.usejavacp.value = true + val res2 = engine.asInstanceOf[javax.script.Compilable] + res2 compile "8" eval() + val res5 = res2 compile """println("hello") ; 8""" + res5 eval() + res5 eval() +} |