diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-05-27 17:50:26 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-05-27 17:50:26 +1000 |
commit | a09ed4854613b27afa8eb9cdbecce0ca47c72ae8 (patch) | |
tree | c91400143b908c0d3aaae265521e379ed35d5703 /test/junit | |
parent | edbf2c42d933ed59e4f5f41c26bfcc8f18915caf (diff) | |
parent | 3873fcfcbcc6c7f0c1660c18e45b265170580546 (diff) | |
download | scala-a09ed4854613b27afa8eb9cdbecce0ca47c72ae8.tar.gz scala-a09ed4854613b27afa8eb9cdbecce0ca47c72ae8.tar.bz2 scala-a09ed4854613b27afa8eb9cdbecce0ca47c72ae8.zip |
Merge pull request #5192 from dwijnand/wip/scala-repl-no-imports
Fully qualify types in REPL generated code
Diffstat (limited to 'test/junit')
-rw-r--r-- | test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala b/test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala index a8dc8eb3e0..01d17110d6 100644 --- a/test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala +++ b/test/junit/scala/tools/nsc/interpreter/ScriptedTest.scala @@ -13,6 +13,14 @@ class ScriptedTest { // same as by service discovery //new ScriptEngineManager().getEngineByName("scala").asInstanceOf[ScriptEngine with Compilable] + // scripted, but also -Yno-predef -Yno-imports + def scriptedNoNothing: ScriptEngine with Compilable = { + val settings = new Settings() + settings.noimports.value = true + settings.nopredef.value = true + Scripted(settings = settings) + } + @Test def eval() = { val engine = scripted engine.put("foo","bar") @@ -24,6 +32,17 @@ class ScriptedTest { assert("barbar" == c.eval()) assert("bazbaz" == c.eval(bindings)) } + @Test def evalNoNothing() = { + val engine = scriptedNoNothing + engine.put("foo","bar") + assert("bar" == engine.eval("foo")) + val bindings = engine.createBindings() + bindings.put("foo","baz") + assert("baz" == engine.eval("foo", bindings)) + val c = engine.compile("import scala.Predef.augmentString ; def f = foo.asInstanceOf[java.lang.String] ; f * 2") + assert("barbar" == c.eval()) + assert("bazbaz" == c.eval(bindings)) + } @Test def `SI-7933 multiple eval compiled script`() = { val engine = scripted val init = """val i = new java.util.concurrent.atomic.AtomicInteger""" |