diff options
author | Som Snytt <som.snytt@gmail.com> | 2013-09-05 22:15:46 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2013-09-06 13:48:08 -0700 |
commit | 06c1c7855510ce31e43356407b95979e1e3813f1 (patch) | |
tree | 7ee9fc4b453e5539c8423e6b690b525c63128cb2 /test/files/run/t7805-repl-i.scala | |
parent | 6dd565ff9b73a3ebc8f702e01d46eca78b423dd9 (diff) | |
download | scala-06c1c7855510ce31e43356407b95979e1e3813f1.tar.gz scala-06c1c7855510ce31e43356407b95979e1e3813f1.tar.bz2 scala-06c1c7855510ce31e43356407b95979e1e3813f1.zip |
SI-7805 REPL -i startup
Tested with a ReplTest that loads an include script.
ReplTests can choose to be `Welcoming` and keep a
normalized welcome message in their check transcript.
One recent SessionTest is updated to use the normalizing API.
Diffstat (limited to 'test/files/run/t7805-repl-i.scala')
-rw-r--r-- | test/files/run/t7805-repl-i.scala | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/files/run/t7805-repl-i.scala b/test/files/run/t7805-repl-i.scala new file mode 100644 index 0000000000..a4061689f0 --- /dev/null +++ b/test/files/run/t7805-repl-i.scala @@ -0,0 +1,42 @@ + +import scala.tools.partest.{ ReplTest, Welcoming } +import scala.tools.nsc.{ GenericRunnerSettings, Settings } +import scala.tools.nsc.settings.MutableSettings + +object Test extends ReplTest with HangingRepl with Welcoming { + def script = testPath changeExtension "script" + override def transformSettings(s: Settings) = s match { + case m: MutableSettings => + val t = new GenericRunnerSettings(s.errorFn) + m copyInto t + t processArgumentString s"-i $script" + t + case _ => s + } + def code = "Console println Try(8)" +} + +object Resulting { + import scala.concurrent._ + import scala.concurrent.duration._ + implicit class AwaitResult[A](val f: Future[A]) extends AnyVal { + def resultWithin(d: Duration): A = Await.result(f, d) + } +} + +/** Test that hangs the REPL. + * Usually that is the "before" case. + */ +trait HangingRepl extends ReplTest { + import scala.language.postfixOps + import scala.util._ + import scala.concurrent._ + import scala.concurrent.duration._ + import ExecutionContext.Implicits._ + import Resulting._ + def timeout = 15 seconds + def hanging[A](a: =>A): A = future(a) resultWithin timeout + override def show() = Try(hanging(super.show())) recover { + case e => e.printStackTrace() + } +} |