diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-02-03 21:59:54 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-02-03 21:59:54 +1000 |
commit | 953559988a698d6663ac983ee7d9944e05bd861d (patch) | |
tree | d2b12610d04c9a510e9d5c2b0242118521fa1a15 /test | |
parent | 6ecb997fa8eb305bf547ec8a6106ba2fd777a594 (diff) | |
parent | bf599bc72a1fff4aa812e6d8962b2cabe14725ab (diff) | |
download | scala-953559988a698d6663ac983ee7d9944e05bd861d.tar.gz scala-953559988a698d6663ac983ee7d9944e05bd861d.tar.bz2 scala-953559988a698d6663ac983ee7d9944e05bd861d.zip |
Merge commit 'bf599bc' into merge/2.11.x-to-2.12.x-20160203
Conflicts:
src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
src/compiler/scala/tools/nsc/transform/Constructors.scala
src/compiler/scala/tools/nsc/typechecker/Contexts.scala
src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala
src/scaladoc/scala/tools/nsc/doc/html/resource/lib/jquery.layout.js
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/innerClassEnclMethodJavaReflection.scala | 9 | ||||
-rw-r--r-- | test/files/presentation/doc/doc.scala | 6 | ||||
-rw-r--r-- | test/files/run/t9567.scala | 18 | ||||
-rw-r--r-- | test/files/run/t9567b.scala | 19 | ||||
-rw-r--r-- | test/files/run/t9567c.scala | 29 | ||||
-rw-r--r-- | test/junit/scala/collection/SearchingTest.scala | 48 | ||||
-rw-r--r-- | test/junit/scala/collection/immutable/VectorTest.scala | 30 |
7 files changed, 155 insertions, 4 deletions
diff --git a/test/files/jvm/innerClassEnclMethodJavaReflection.scala b/test/files/jvm/innerClassEnclMethodJavaReflection.scala index a4d64d0b67..a60b5cac8e 100644 --- a/test/files/jvm/innerClassEnclMethodJavaReflection.scala +++ b/test/files/jvm/innerClassEnclMethodJavaReflection.scala @@ -25,12 +25,13 @@ object Test extends App { def testClasses(jarOrDirectory: String): Unit = { val classPath = AbstractFile.getDirectory(new java.io.File(jarOrDirectory)) + val basePath = classPath.path + "/" - def flatten(f: AbstractFile): Iterator[AbstractFile] = - if (f.isClassContainer) f.iterator.flatMap(flatten) - else Iterator(f) + def flatten(f: AbstractFile, s: String): Iterator[(AbstractFile, String)] = + if (f.isClassContainer) f.iterator.map(ch => (ch, (if(s.isEmpty) "" else s + "/") + ch.name)).flatMap((flatten _).tupled) + else Iterator((f, s)) - val classFullNames = flatten(classPath).filter(_.hasExtension("class")).map(_.path.replace("/", ".").replaceAll(".class$", "")) + val classFullNames = flatten(classPath, "").filter(_._1.hasExtension("class")).map(_._2.replace("/", ".").replaceAll(".class$", "")) // it seems that Class objects can only be GC'd together with their class loader // (http://stackoverflow.com/questions/2433261/when-and-how-are-classes-garbage-collected-in-java) diff --git a/test/files/presentation/doc/doc.scala b/test/files/presentation/doc/doc.scala index f2233f1828..ce431910ee 100644 --- a/test/files/presentation/doc/doc.scala +++ b/test/files/presentation/doc/doc.scala @@ -118,6 +118,12 @@ object Test extends InteractiveTest { } } + // The remainder of this test has been found to fail intermittently on Windows + // only. The problem is difficult to isolate and reproduce; see + // https://github.com/scala/scala-dev/issues/72 for details. + // So if we're on Windows, let's just bail out here. + if (scala.util.Properties.isWin) return + // Check inter-classes documentation one-time retrieved ok. val baseSource = findSource("Base.scala") val derivedSource = findSource("Derived.scala") diff --git a/test/files/run/t9567.scala b/test/files/run/t9567.scala new file mode 100644 index 0000000000..69896b8650 --- /dev/null +++ b/test/files/run/t9567.scala @@ -0,0 +1,18 @@ +object Test { + def testMethodLocalCaseClass { + case class MethodLocalWide( + f01: Int, f02: Int, f03: Int, f04: Int, f05: Int, f06: Int, f07: Int, f08: Int, f09: Int, f10: Int, + f11: Int, f12: Int, f13: Int, f14: Int, f15: Int, f16: Int, f17: Int, f18: Int, f19: Int, f20: Int, + f21: Int, f22: Int, f23: Int) + + val instance = MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val result = instance match { + case MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) => true + case _ => false + } + assert(result) + } + def main(args: Array[String]) { + testMethodLocalCaseClass + } +} diff --git a/test/files/run/t9567b.scala b/test/files/run/t9567b.scala new file mode 100644 index 0000000000..88cef0a60e --- /dev/null +++ b/test/files/run/t9567b.scala @@ -0,0 +1,19 @@ +object Test { + def testMethodLocalCaseClass { + object MethodLocalWide + case class MethodLocalWide( + f01: Int, f02: Int, f03: Int, f04: Int, f05: Int, f06: Int, f07: Int, f08: Int, f09: Int, f10: Int, + f11: Int, f12: Int, f13: Int, f14: Int, f15: Int, f16: Int, f17: Int, f18: Int, f19: Int, f20: Int, + f21: Int, f22: Int, f23: Int) + + val instance = MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val result = instance match { + case MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) => true + case _ => false + } + assert(result) + } + def main(args: Array[String]) { + testMethodLocalCaseClass + } +} diff --git a/test/files/run/t9567c.scala b/test/files/run/t9567c.scala new file mode 100644 index 0000000000..560bea8821 --- /dev/null +++ b/test/files/run/t9567c.scala @@ -0,0 +1,29 @@ +case class CaseSequenceTopLevel(as: Int*) + +object Test { + def main(args: Array[String]): Unit = { + + val buffer1 = collection.mutable.Buffer(0, 0) + CaseSequenceTopLevel(buffer1: _*) match { + case CaseSequenceTopLevel(_, i) => + buffer1(1) = 1 + assert(i == 0, i) // fails in 2.11.7 -optimize + } + + case class CaseSequence(as: Int*) + val buffer2 = collection.mutable.Buffer(0, 0) + CaseSequence(buffer2: _*) match { + case CaseSequence(_, i) => + buffer2(1) = 1 + assert(i == 0, i) + } + + case class CaseSequenceWithVar(var x: Any, as: Int*) + val buffer3 = collection.mutable.Buffer(0, 0) + CaseSequenceWithVar("", buffer3: _*) match { + case CaseSequenceWithVar(_, _, i) => // crashes in 2.11.7 + buffer2(1) = 1 + assert(i == 0, i) + } + } +} diff --git a/test/junit/scala/collection/SearchingTest.scala b/test/junit/scala/collection/SearchingTest.scala new file mode 100644 index 0000000000..2f939d625e --- /dev/null +++ b/test/junit/scala/collection/SearchingTest.scala @@ -0,0 +1,48 @@ +package scala.collection + +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Assert._ +import org.junit.Test +import scala.collection.Searching._ + +@RunWith(classOf[JUnit4]) +class SearchingTest { + + @Test + def doesLinearSearchOnLinearSeqs() { + + class TestSeq[A](list: List[A]) extends SeqLike[A, TestSeq[A]] { + var elementsAccessed = Set.empty[Int] + + protected[this] def newBuilder = ??? // not needed for this test + def seq = list + def iterator = list.iterator + def length = list.length + def apply(idx: Int) = { elementsAccessed += idx; list(idx) } + } + + val coll = new TestSeq((0 to 6).toList) + + assertEquals(Found(5), coll.search(5)) + assertEquals(Set.empty, coll.elementsAccessed) // linear search should not access elements via apply() + } + + @Test + def doesBinarySearchOnIndexedSeqs() { + + class TestIndexedSeq[A](vec: Vector[A]) extends IndexedSeqLike[A, TestIndexedSeq[A]] { + var elementsAccessed = Set.empty[Int] + + protected[this] def newBuilder = ??? // not needed for this test + def seq = vec + def length = vec.length + def apply(idx: Int) = { elementsAccessed += idx; vec(idx) } + } + + val coll = new TestIndexedSeq((0 to 6).toVector) + + assertEquals(Found(5), coll.search(5)) + assertEquals(Set(3, 5), coll.elementsAccessed) + } +} diff --git a/test/junit/scala/collection/immutable/VectorTest.scala b/test/junit/scala/collection/immutable/VectorTest.scala new file mode 100644 index 0000000000..69f74872d0 --- /dev/null +++ b/test/junit/scala/collection/immutable/VectorTest.scala @@ -0,0 +1,30 @@ +package scala.collection.immutable + +import org.junit.Assert._ +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test + +@RunWith(classOf[JUnit4]) +class VectorTest { + + @Test + def hasCorrectDropAndTakeMethods() { + val v = Vector(0) ++ Vector(1 to 64: _*) + + assertEquals(Vector(0, 1), v take 2) + assertEquals(Vector(63, 64), v takeRight 2) + assertEquals(Vector(2 to 64: _*), v drop 2) + assertEquals(Vector(0 to 62: _*), v dropRight 2) + + assertEquals(v, v take Int.MaxValue) + assertEquals(v, v takeRight Int.MaxValue) + assertEquals(Vector.empty[Int], v drop Int.MaxValue) + assertEquals(Vector.empty[Int], v dropRight Int.MaxValue) + + assertEquals(Vector.empty[Int], v take Int.MinValue) + assertEquals(Vector.empty[Int], v takeRight Int.MinValue) + assertEquals(v, v drop Int.MinValue) + assertEquals(v, v dropRight Int.MinValue) + } +} |