summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-09-07 19:56:16 -0700
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-09-07 19:56:16 -0700
commit65d5f1dc657d4f73a7ef18488f81e93b96173890 (patch)
tree62d51e80836f23d8a6a219ddc3f3917c6215fcb6 /test
parentb2cf65d3d9a216fa1ffcbf59412326edb71c411d (diff)
parent06c1c7855510ce31e43356407b95979e1e3813f1 (diff)
downloadscala-65d5f1dc657d4f73a7ef18488f81e93b96173890.tar.gz
scala-65d5f1dc657d4f73a7ef18488f81e93b96173890.tar.bz2
scala-65d5f1dc657d4f73a7ef18488f81e93b96173890.zip
Merge pull request #2917 from som-snytt/issue/7805-repl-i
SI-7805 REPL -i startup
Diffstat (limited to 'test')
-rw-r--r--test/files/run/repl-trim-stack-trace.scala11
-rw-r--r--test/files/run/t7805-repl-i.check11
-rw-r--r--test/files/run/t7805-repl-i.scala42
-rw-r--r--test/files/run/t7805-repl-i.script1
4 files changed, 60 insertions, 5 deletions
diff --git a/test/files/run/repl-trim-stack-trace.scala b/test/files/run/repl-trim-stack-trace.scala
index 0f4a43bc85..70ee8e1840 100644
--- a/test/files/run/repl-trim-stack-trace.scala
+++ b/test/files/run/repl-trim-stack-trace.scala
@@ -1,10 +1,11 @@
-import scala.tools.partest.SessionTest
+import scala.tools.partest.{ SessionTest, Welcoming }
// SI-7740
-object Test extends SessionTest {
+object Test extends SessionTest with Welcoming {
def session =
-"""Type in expressions to have them evaluated.
+"""Welcome to Scala
+Type in expressions to have them evaluated.
Type :help for more information.
scala> def f = throw new Exception("Uh-oh")
@@ -35,10 +36,10 @@ scala> """
// normalize the "elided" lines because the frame count depends on test context
lazy val elided = """(\s+\.{3} )\d+( elided)""".r
- def normalize(line: String) = line match {
+ override def normalize(line: String) = line match {
+ case welcome(w) => w
case elided(ellipsis, suffix) => s"$ellipsis???$suffix"
case s => s
}
- override def eval() = super.eval() map normalize
override def expected = super.expected map normalize
}
diff --git a/test/files/run/t7805-repl-i.check b/test/files/run/t7805-repl-i.check
new file mode 100644
index 0000000000..eecfff079a
--- /dev/null
+++ b/test/files/run/t7805-repl-i.check
@@ -0,0 +1,11 @@
+Loading t7805-repl-i.script...
+import util._
+
+Welcome to Scala
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> Console println Try(8)
+Success(8)
+
+scala>
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()
+ }
+}
diff --git a/test/files/run/t7805-repl-i.script b/test/files/run/t7805-repl-i.script
new file mode 100644
index 0000000000..eb2b8705f3
--- /dev/null
+++ b/test/files/run/t7805-repl-i.script
@@ -0,0 +1 @@
+import util._