aboutsummaryrefslogtreecommitdiff
path: root/tests/repl
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-03-17 16:19:03 +0100
committerMartin Odersky <odersky@gmail.com>2016-03-18 12:25:47 +0100
commite1fb19412c5dcc722e7df24e543aadf03a463c9a (patch)
tree15c3732fba37b8b609c09b0632edd63fd0b59f77 /tests/repl
parent57bde5b5c31b76c687649848bbe2207ebeb7a57d (diff)
downloaddotty-e1fb19412c5dcc722e7df24e543aadf03a463c9a.tar.gz
dotty-e1fb19412c5dcc722e7df24e543aadf03a463c9a.tar.bz2
dotty-e1fb19412c5dcc722e7df24e543aadf03a463c9a.zip
Add REPL tests
Diffstat (limited to 'tests/repl')
-rw-r--r--tests/repl/import.check11
-rw-r--r--tests/repl/multilines.check33
-rw-r--r--tests/repl/onePlusOne.check3
3 files changed, 47 insertions, 0 deletions
diff --git a/tests/repl/import.check b/tests/repl/import.check
new file mode 100644
index 000000000..ccaa52190
--- /dev/null
+++ b/tests/repl/import.check
@@ -0,0 +1,11 @@
+scala> import collection.mutable._
+import collection.mutable._
+scala> val buf = new ListBuffer[Int]
+buf: scala.collection.mutable.ListBuffer[Int] = ListBuffer()
+scala> buf += 22
+res0: scala.collection.mutable.ListBuffer[Int] = ListBuffer(22)
+scala> buf ++= List(1, 2, 3)
+res1: scala.collection.mutable.ListBuffer[Int] = ListBuffer(22, 1, 2, 3)
+scala> buf.toList
+res2: scala.collection.immutable.List[Int] = List(22, 1, 2, 3)
+scala> :quit
diff --git a/tests/repl/multilines.check b/tests/repl/multilines.check
new file mode 100644
index 000000000..3bc32707e
--- /dev/null
+++ b/tests/repl/multilines.check
@@ -0,0 +1,33 @@
+scala> val x = """alpha
+ |
+ | omega"""
+x: String =
+alpha
+
+omega
+scala> val y = """abc
+ | |def
+ | |ghi
+ | """.stripMargin
+y: String =
+abc
+def
+ghi
+
+scala> val z = {
+ | def square(x: Int) = x * x
+ | val xs = List(1, 2, 3)
+ | square(xs)
+ | }
+<console>:8: error: type mismatch:
+ found : scala.collection.immutable.List[Int](xs)
+ required: Int
+ square(xs)
+ ^
+scala> val z = {
+ | def square(x: Int) = x * x
+ | val xs = List(1, 2, 3)
+ | xs.map(square)
+ | }
+z: scala.collection.immutable.List[Int] = List(1, 4, 9)
+scala> :quit
diff --git a/tests/repl/onePlusOne.check b/tests/repl/onePlusOne.check
new file mode 100644
index 000000000..9db6e6817
--- /dev/null
+++ b/tests/repl/onePlusOne.check
@@ -0,0 +1,3 @@
+scala> 1+1
+res0: Int = 2
+scala> :quit