diff options
author | odersky <odersky@gmail.com> | 2016-03-31 11:20:48 +0200 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2016-03-31 11:20:48 +0200 |
commit | 5bd08d437c1365bd8a81cb1b6b9801b443fde96b (patch) | |
tree | e2be21f89de19da9b7ce2ea2391c7cc300f4c515 /tests | |
parent | 8cafcb9455103c34b6ce4344b58ca472a3a1f034 (diff) | |
parent | ef8c1968b2ea407c5b2ddca2fef00eb922e81f8e (diff) | |
download | dotty-5bd08d437c1365bd8a81cb1b6b9801b443fde96b.tar.gz dotty-5bd08d437c1365bd8a81cb1b6b9801b443fde96b.tar.bz2 dotty-5bd08d437c1365bd8a81cb1b6b9801b443fde96b.zip |
Merge pull request #1182 from dotty-staging/repl-fixes
Repl fixes and tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/repl/import.check | 11 | ||||
-rw-r--r-- | tests/repl/imports.check | 24 | ||||
-rw-r--r-- | tests/repl/multilines.check | 33 | ||||
-rw-r--r-- | tests/repl/onePlusOne.check | 3 |
4 files changed, 71 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/imports.check b/tests/repl/imports.check new file mode 100644 index 000000000..3fa103283 --- /dev/null +++ b/tests/repl/imports.check @@ -0,0 +1,24 @@ +scala> import scala.collection.mutable +import scala.collection.mutable +scala> val buf = mutable.ListBuffer[Int]() +buf: scala.collection.mutable.ListBuffer[Int] = ListBuffer() +scala> object o { + | val xs = List(1, 2, 3) + | } +defined module o +scala> import o._ +import o._ +scala> buf += xs +<console>:11: error: type mismatch: + found : scala.collection.immutable.List[Int](o.xs) + required: String +buf += xs + ^ +<console>:11: error: type mismatch: + found : String + required: scala.collection.mutable.ListBuffer[Int] +buf += xs +^ +scala> buf ++= xs +res1: scala.collection.mutable.ListBuffer[Int] = ListBuffer(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 |