summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/disabled/presentation/akka/src/akka/actor/Supervisor.scala2
-rw-r--r--test/files/neg/depmet_1.check4
-rw-r--r--test/files/neg/macro-without-xmacros-a.check2
-rw-r--r--test/files/neg/macro-without-xmacros-b.check2
-rw-r--r--test/files/neg/t6040.check2
-rw-r--r--test/files/neg/t6120.check2
-rw-r--r--test/files/neg/t6952.check2
-rw-r--r--test/files/neg/t8736-c.check2
-rw-r--r--test/files/pos/existental-slow-compile2.scala7
-rw-r--r--test/files/pos/existential-slow-compile1.flags1
-rw-r--r--test/files/pos/existential-slow-compile1.scala7
-rw-r--r--test/files/run/t3647.check1
-rw-r--r--test/files/run/t4950.check7
-rw-r--r--test/files/run/t4950.scala24
-rw-r--r--test/files/run/t7634.check4
-rw-r--r--test/files/run/t7634.scala2
-rw-r--r--test/junit/scala/PartialFunctionSerializationTest.scala36
-rw-r--r--test/junit/scala/collection/mutable/SetLikeTest.scala26
-rw-r--r--test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala73
-rwxr-xr-xtest/partest8
-rw-r--r--test/scaladoc/resources/links.scala2
-rw-r--r--test/scaladoc/run/links.scala2
22 files changed, 191 insertions, 27 deletions
diff --git a/test/disabled/presentation/akka/src/akka/actor/Supervisor.scala b/test/disabled/presentation/akka/src/akka/actor/Supervisor.scala
index 4a1309faef..bec3c83f1a 100644
--- a/test/disabled/presentation/akka/src/akka/actor/Supervisor.scala
+++ b/test/disabled/presentation/akka/src/akka/actor/Supervisor.scala
@@ -95,7 +95,7 @@ case class SupervisorFactory(val config: SupervisorConfig) {
* wire the children together using 'link', 'spawnLink' etc. and set the 'trapExit' flag in the
* children that should trap error signals and trigger restart.
* <p/>
- * See the ScalaDoc for the SupervisorFactory for an example on how to declaratively wire up children.
+ * See the Scaladoc for the SupervisorFactory for an example on how to declaratively wire up children.
*
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
diff --git a/test/files/neg/depmet_1.check b/test/files/neg/depmet_1.check
index 7a4f845fd5..15498568c5 100644
--- a/test/files/neg/depmet_1.check
+++ b/test/files/neg/depmet_1.check
@@ -1,7 +1,7 @@
-depmet_1.scala:2: error: illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one
+depmet_1.scala:2: error: illegal dependent method type: parameter may only be referenced in a subsequent parameter section
def precise0(y: x.type)(x: String): Unit = {}
^
-depmet_1.scala:3: error: illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one
+depmet_1.scala:3: error: illegal dependent method type: parameter may only be referenced in a subsequent parameter section
def precise1(x: String, y: x.type): Unit = {}
^
depmet_1.scala:4: error: not found: value y
diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check
index ec194be3a9..65445d80dd 100644
--- a/test/files/neg/macro-without-xmacros-a.check
+++ b/test/files/neg/macro-without-xmacros-a.check
@@ -2,7 +2,7 @@ Macros_2.scala:5: error: macro definition needs to be enabled
by making the implicit value scala.language.experimental.macros visible.
This can be achieved by adding the import clause 'import scala.language.experimental.macros'
or by setting the compiler option -language:experimental.macros.
-See the Scala docs for value scala.language.experimental.macros for a discussion
+See the Scaladoc for value scala.language.experimental.macros for a discussion
why the feature needs to be explicitly enabled.
def foo(x: Int): Int = macro foo_impl
^
diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check
index c97850f0a9..e3c1010d50 100644
--- a/test/files/neg/macro-without-xmacros-b.check
+++ b/test/files/neg/macro-without-xmacros-b.check
@@ -2,7 +2,7 @@ Macros_2.scala:3: error: macro definition needs to be enabled
by making the implicit value scala.language.experimental.macros visible.
This can be achieved by adding the import clause 'import scala.language.experimental.macros'
or by setting the compiler option -language:experimental.macros.
-See the Scala docs for value scala.language.experimental.macros for a discussion
+See the Scaladoc for value scala.language.experimental.macros for a discussion
why the feature needs to be explicitly enabled.
def foo(x: Int): Int = macro Impls.foo_impl
^
diff --git a/test/files/neg/t6040.check b/test/files/neg/t6040.check
index 16c90ede7e..350f796d18 100644
--- a/test/files/neg/t6040.check
+++ b/test/files/neg/t6040.check
@@ -2,7 +2,7 @@ t6040.scala:1: error: extension of type scala.Dynamic needs to be enabled
by making the implicit value scala.language.dynamics visible.
This can be achieved by adding the import clause 'import scala.language.dynamics'
or by setting the compiler option -language:dynamics.
-See the Scala docs for value scala.language.dynamics for a discussion
+See the Scaladoc for value scala.language.dynamics for a discussion
why the feature needs to be explicitly enabled.
class X extends Dynamic
^
diff --git a/test/files/neg/t6120.check b/test/files/neg/t6120.check
index a7d17e29cf..f432fde32f 100644
--- a/test/files/neg/t6120.check
+++ b/test/files/neg/t6120.check
@@ -2,7 +2,7 @@ t6120.scala:5: warning: postfix operator bippy should be enabled
by making the implicit value scala.language.postfixOps visible.
This can be achieved by adding the import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
-See the Scala docs for value scala.language.postfixOps for a discussion
+See the Scaladoc for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
def f = null == null bippy
^
diff --git a/test/files/neg/t6952.check b/test/files/neg/t6952.check
index 1a591d02c6..acee0e7d60 100644
--- a/test/files/neg/t6952.check
+++ b/test/files/neg/t6952.check
@@ -2,7 +2,7 @@ t6952.scala:2: error: extension of type scala.Dynamic needs to be enabled
by making the implicit value scala.language.dynamics visible.
This can be achieved by adding the import clause 'import scala.language.dynamics'
or by setting the compiler option -language:dynamics.
-See the Scala docs for value scala.language.dynamics for a discussion
+See the Scaladoc for value scala.language.dynamics for a discussion
why the feature needs to be explicitly enabled.
trait B extends Dynamic
^
diff --git a/test/files/neg/t8736-c.check b/test/files/neg/t8736-c.check
index 06b2228543..7debb6d515 100644
--- a/test/files/neg/t8736-c.check
+++ b/test/files/neg/t8736-c.check
@@ -2,7 +2,7 @@ t8736-c.scala:4: warning: higher-kinded type should be enabled
by making the implicit value scala.language.higherKinds visible.
This can be achieved by adding the import clause 'import scala.language.higherKinds'
or by setting the compiler option -language:higherKinds.
-See the Scala docs for value scala.language.higherKinds for a discussion
+See the Scaladoc for value scala.language.higherKinds for a discussion
why the feature should be explicitly enabled.
def hk[M[_]] = ???
^
diff --git a/test/files/pos/existental-slow-compile2.scala b/test/files/pos/existental-slow-compile2.scala
new file mode 100644
index 0000000000..907344982c
--- /dev/null
+++ b/test/files/pos/existental-slow-compile2.scala
@@ -0,0 +1,7 @@
+class C {
+ class L[+A]
+ def test = {
+ val foo:
+ L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_]]]]]]]]]]]]]]]]]]]]]]]]
+ = ??? } }
+
diff --git a/test/files/pos/existential-slow-compile1.flags b/test/files/pos/existential-slow-compile1.flags
new file mode 100644
index 0000000000..7f7581974d
--- /dev/null
+++ b/test/files/pos/existential-slow-compile1.flags
@@ -0,0 +1 @@
+-Ystop-after:refchecks
diff --git a/test/files/pos/existential-slow-compile1.scala b/test/files/pos/existential-slow-compile1.scala
new file mode 100644
index 0000000000..8602afd9db
--- /dev/null
+++ b/test/files/pos/existential-slow-compile1.scala
@@ -0,0 +1,7 @@
+class C {
+ type L[+A] = scala.collection.immutable.List[A]
+ def test = {
+ val foo:
+ L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_]]]]]]]]]]]]]]]]]]]]]]]]
+ = ??? } }
+
diff --git a/test/files/run/t3647.check b/test/files/run/t3647.check
new file mode 100644
index 0000000000..e5c1ee1701
--- /dev/null
+++ b/test/files/run/t3647.check
@@ -0,0 +1 @@
+warning: there were three deprecation warnings; re-run with -deprecation for details
diff --git a/test/files/run/t4950.check b/test/files/run/t4950.check
deleted file mode 100644
index 8994441163..0000000000
--- a/test/files/run/t4950.check
+++ /dev/null
@@ -1,7 +0,0 @@
-
-scala> val 1 = 2
-scala.MatchError: 2 (of class java.lang.Integer)
-
-scala> val List(1) = List(1)
-
-scala> :quit
diff --git a/test/files/run/t4950.scala b/test/files/run/t4950.scala
index cef06027bf..e34b2cf3f2 100644
--- a/test/files/run/t4950.scala
+++ b/test/files/run/t4950.scala
@@ -1,12 +1,24 @@
-import scala.tools.partest.ReplTest
+import scala.tools.partest.SessionTest
+import scala.PartialFunction.{ cond => when }
+
+object Elision {
+ val elideMsg = """ ... \d+ elided""".r
+}
+
+object Test extends SessionTest {
+ import Elision._
-object Test extends ReplTest {
// Filter out the abbreviated stacktrace "... X elided"
// because the number seems to differ between versions/platforms/...
- override def show = eval() filterNot (_ contains "elided") foreach println
- def code =
+ def elided(s: String) = when(s) { case elideMsg() => true }
+ override def eval() = super.eval() filterNot elided
+ def session =
"""
-val 1 = 2
-val List(1) = List(1)
+scala> val 1 = 2
+scala.MatchError: 2 (of class java.lang.Integer)
+
+scala> val List(1) = List(1)
+
+scala> :quit
"""
}
diff --git a/test/files/run/t7634.check b/test/files/run/t7634.check
index 879aea67a2..43128cad95 100644
--- a/test/files/run/t7634.check
+++ b/test/files/run/t7634.check
@@ -1,6 +1,6 @@
-scala> .lines
-res1: List[String] = List(shello, world.)
+scala> .lines.foreach(println)
+shello, world.
scala> :quit
diff --git a/test/files/run/t7634.scala b/test/files/run/t7634.scala
index aeb6a5e671..9520931941 100644
--- a/test/files/run/t7634.scala
+++ b/test/files/run/t7634.scala
@@ -9,7 +9,7 @@ import scala.util.Properties.propOrElse
object Test extends ReplTest {
def java = propOrElse("javacmd", "java")
def code = s""":sh $java -classpath $testOutput hello.Hello
- |.lines""".stripMargin
+ |.lines.foreach(println)""".stripMargin
}
package hello {
diff --git a/test/junit/scala/PartialFunctionSerializationTest.scala b/test/junit/scala/PartialFunctionSerializationTest.scala
new file mode 100644
index 0000000000..d525b045cd
--- /dev/null
+++ b/test/junit/scala/PartialFunctionSerializationTest.scala
@@ -0,0 +1,36 @@
+package scala
+
+import org.junit.Test
+import org.junit.Assert._
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class PartialFunctionSerializationTest {
+ val pf1: PartialFunction[Int, Int] = {
+ case n if n > 0 => 1
+ }
+
+ val pf2: PartialFunction[Int, Int] = {
+ case n if n <= 0 => 2
+ }
+
+
+ private def assertSerializable[A,B](fn: A => B) = {
+ import java.io._
+
+ new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(fn)
+ }
+
+ @Test def canSerializeLiteral= assertSerializable(pf1)
+
+ @Test def canSerializeLifted= assertSerializable(pf1.lift)
+
+ @Test def canSerializeOrElse = assertSerializable(pf1 orElse pf2)
+
+ @Test def canSerializeUnlifted = assertSerializable(Function.unlift((x: Int) => Some(x)))
+
+ @Test def canSerializeAndThen = assertSerializable(pf1.andThen((x: Int) => x))
+
+ @Test def canSerializeEmpty = assertSerializable(PartialFunction.empty)
+}
diff --git a/test/junit/scala/collection/mutable/SetLikeTest.scala b/test/junit/scala/collection/mutable/SetLikeTest.scala
new file mode 100644
index 0000000000..c819024558
--- /dev/null
+++ b/test/junit/scala/collection/mutable/SetLikeTest.scala
@@ -0,0 +1,26 @@
+package scala.collection.mutable
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class SetLikeTest {
+
+ class MySet(self: Set[String]) extends Set[String] with SetLike[String, MySet] {
+ override def -=(elem: String) = { self -= elem; this }
+ override def +=(elem: String) = { self += elem; this }
+
+ override def empty = new MySet(self.empty)
+ override def iterator = self.iterator
+ override def contains(elem: String) = self.contains(elem)
+ }
+
+ @Test
+ def hasCorrectClear() {
+ val s = new MySet(Set("EXPOSEDNODE", "CONNECTABLE"))
+ s.clear()
+ assertEquals(new MySet(Set()), s)
+ }
+}
diff --git a/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala b/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala
new file mode 100644
index 0000000000..010078e28a
--- /dev/null
+++ b/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala
@@ -0,0 +1,73 @@
+package scala.tools.nsc.transform.delambdafy
+
+import scala.reflect.io.Path.jfile2path
+import scala.tools.nsc.backend.jvm.CodeGenTools.getGeneratedClassfiles
+import scala.tools.nsc.backend.jvm.CodeGenTools.makeSourceFile
+import scala.tools.nsc.backend.jvm.CodeGenTools.newCompilerWithoutVirtualOutdir
+import scala.tools.nsc.io.AbstractFile
+import scala.tools.testing.TempDir
+
+import org.junit.Assert.assertTrue
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class DelambdafyTest {
+ def compileToMultipleOutputWithDelamdbafyMethod(): List[(String, Array[Byte])] = {
+ val codeForMultiOutput = """
+object Delambdafy {
+ type -->[D, I] = PartialFunction[D, I]
+
+ def main(args: Array[String]): Unit = {
+ val result = List(1, 2, 4).map { a =>
+ val list = List("1", "2", "3").map { _ + "test" }
+ list.find { _ == a.toString + "test" }
+ }
+ println(result)
+ lazy val _foo = foo(result) {
+ case x :: xs if x isDefined => x.get.length
+ case _ => 0
+ }
+ println(_foo)
+ lazy val bar: Int => Int = {
+ case 2 => 23
+ case _ =>
+ val v = List(1).map { _ + 42 }.head
+ v + 31
+ }
+ bar(3)
+ lazy val _baz = baz {
+ case 1 =>
+ val local = List(1).map(_ + 1)
+ local.head
+ }
+ }
+
+ def baz[T](f: Any --> Any): Any => Any = f
+
+ def foo(b: List[Option[String]])(a: List[Option[String]] => Int): Int = a(b)
+}
+"""
+ val srcFile = makeSourceFile(codeForMultiOutput, "delambdafyTest.scala")
+ val outDir = AbstractFile.getDirectory(TempDir.createTempDir())
+ val outDirPath = outDir.canonicalPath
+ val extraArgs = "-Ybackend:GenBCode -Ydelambdafy:method"
+ val argsWithOutDir = extraArgs + s" -d $outDirPath -cp $outDirPath"
+ val compiler = newCompilerWithoutVirtualOutdir(extraArgs = argsWithOutDir)
+ compiler.settings.outputDirs.add(srcFile.file, outDir)
+
+ new compiler.Run().compileSources(List(srcFile))
+
+ val classfiles = getGeneratedClassfiles(outDir)
+ outDir.delete()
+ classfiles
+ }
+
+ @Test
+ def shouldFindOutputFoldersForAllPromotedLambdasAsMethod(): Unit = {
+ val actual = compileToMultipleOutputWithDelamdbafyMethod()
+
+ assertTrue(actual.length > 0)
+ }
+}
diff --git a/test/partest b/test/partest
index 6f14dfe1bc..07a5de12af 100755
--- a/test/partest
+++ b/test/partest
@@ -22,6 +22,14 @@ findScalaHome () {
}
# Use tput to detect color-capable terminal.
+# (note: I have found that on Cygwin, the script sometimes dies here.
+# it doesn't happen from the Cygwin prompt when ssh'ing in to
+# jenkins-worker-windows-publish, only when I make a Jenkins job
+# that runs this script. I don't know why. it may have to do with
+# which bash flags are set (-e? -x?) and with bash flags propagating
+# from one script to another? not sure. anyway, normally in a CI
+# context we run partest through ant, not through this script, so I'm
+# not investigating further for now.)
term_colors=$(tput colors 2>/dev/null)
if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then
git_diff_options="--color=always --word-diff"
diff --git a/test/scaladoc/resources/links.scala b/test/scaladoc/resources/links.scala
index ecac9c63cf..8e000ab979 100644
--- a/test/scaladoc/resources/links.scala
+++ b/test/scaladoc/resources/links.scala
@@ -1,6 +1,6 @@
// that would be:
// SI-5079 "Scaladoc can't link to an object (only a class or trait)"
-// SI-4497 "Links in ScalaDoc - Spec and implementation unsufficient"
+// SI-4497 "Links in Scaladoc - Spec and implementation unsufficient"
// SI-4224 "Wiki-links should support method targets"
// SI-3695 "support non-fully-qualified type links in scaladoc comments"
// SI-6487 "Scaladoc can't link to inner classes"
diff --git a/test/scaladoc/run/links.scala b/test/scaladoc/run/links.scala
index 64441c2d95..01db66aec3 100644
--- a/test/scaladoc/run/links.scala
+++ b/test/scaladoc/run/links.scala
@@ -3,7 +3,7 @@ import scala.tools.nsc.doc.model._
import scala.tools.partest.ScaladocModelTest
// SI-5079 "Scaladoc can't link to an object (only a class or trait)"
-// SI-4497 "Links in ScalaDoc - Spec and implementation unsufficient"
+// SI-4497 "Links in Scaladoc - Spec and implementation unsufficient"
// SI-4224 "Wiki-links should support method targets"
// SI-3695 "support non-fully-qualified type links in scaladoc comments"
// SI-6487 "Scaladoc can't link to inner classes"