summaryrefslogtreecommitdiff
path: root/test/disabled
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-05-06 16:37:13 +0000
committerPaul Phillips <paulp@improving.org>2010-05-06 16:37:13 +0000
commitc55b106f503d5e712e69823cfeb1cab2460221eb (patch)
treea1af091d9a2eeb16ee4747930511db4996c47140 /test/disabled
parentcb35c38f14f6a53c38966bde8e64dcfa9af17918 (diff)
downloadscala-c55b106f503d5e712e69823cfeb1cab2460221eb.tar.gz
scala-c55b106f503d5e712e69823cfeb1cab2460221eb.tar.bz2
scala-c55b106f503d5e712e69823cfeb1cab2460221eb.zip
Rolled partest back to r21328.
changes necessary to plug it back in while preserving everything which has happened since then in tests and such, but we should be the lookout for overreversion. Review by phaller (but as a formality, I don't think it requires direct review.)
Diffstat (limited to 'test/disabled')
-rw-r--r--test/disabled/pos/spec-traits.scala83
-rw-r--r--test/disabled/pos/t1254/t1254.java28
-rw-r--r--test/disabled/run/stream_length.check1
-rw-r--r--test/disabled/run/stream_length.scala15
-rw-r--r--test/disabled/run/t2946/Parsers.scala4
-rw-r--r--test/disabled/run/t2946/ResponseCommon.scala14
-rw-r--r--test/disabled/run/t2946/Test.scala7
-rw-r--r--test/disabled/scalacheck/redblack.scala157
8 files changed, 309 insertions, 0 deletions
diff --git a/test/disabled/pos/spec-traits.scala b/test/disabled/pos/spec-traits.scala
new file mode 100644
index 0000000000..9e339a14ad
--- /dev/null
+++ b/test/disabled/pos/spec-traits.scala
@@ -0,0 +1,83 @@
+trait A[@specialized(Int) T] { def foo: T }
+class B extends A[Int] { val foo = 10 }
+class C extends B
+
+// issue 3309
+class Lazy {
+ def test[U](block: => U): Unit = { block }
+
+ test { lazy val x = 1 }
+}
+
+// issue 3307
+class Bug3307 {
+ def f[Z](block: String => Z) {
+ block("abc")
+ }
+
+ ({ () =>
+ f { implicit x => println(x) } })()
+}
+
+// issue 3301
+ trait T[X]
+
+class Bug3301 {
+ def t[A]: T[A] = error("stub")
+
+ () => {
+ type X = Int
+
+ def foo[X] = t[X]
+ ()
+ }
+}
+// issue 3299
+object Failure {
+ def thunk() {
+ for (i <- 1 to 2) {
+ val Array(a, b) = Array(1,2)
+ ()
+ }
+ }
+}
+
+// issue 3296
+
+object AA
+{
+ def f(block: => Unit) {}
+
+ object BB
+ {
+ f {
+ object CC
+
+ ()
+ }
+ }
+
+ def foo[T](x: T) = { object A; false }
+}
+
+// issue 3292
+import scala.swing._
+import scala.swing.GridBagPanel._
+
+object Grid {
+
+ def later(code : => Unit) =
+ javax.swing.SwingUtilities.invokeLater(new Runnable { def run { code }})
+
+ def test = later {
+ val frame = new Dialog {
+ contents = new GridBagPanel {
+ val c = new Constraints
+ }
+ }
+ }
+
+}
+
+// issue 3325
+object O { def f[@specialized T] { for(k <- Nil: List[T]) { } } }
diff --git a/test/disabled/pos/t1254/t1254.java b/test/disabled/pos/t1254/t1254.java
new file mode 100644
index 0000000000..25b733cf28
--- /dev/null
+++ b/test/disabled/pos/t1254/t1254.java
@@ -0,0 +1,28 @@
+/* Taken from ticket #1254. Tests Java signatures in mirror classes and that
+ Nothing is translated to Nothing$.
+*/
+
+import scala.None;
+
+// This compiles with javac but fails with Eclipse java compiler:
+// 'The type scala.Nothing cannot be resolved. It is indirectly referenced from required .class files'
+class NothingBug3 {
+ public NothingBug3() {
+ scala.Option<?> o = scala.None$.MODULE$;
+
+ test(o);
+ None.toLeft(new scala.Function0<Integer>() {
+ public Integer apply() { return 0; }
+ });
+ }
+
+ public <T>void test(scala.Option<T> f) {}
+}
+
+// This compiles with javac but fails with Eclipse java compiler:
+// 'The type scala.Nothing cannot be resolved. It is indirectly referenced from required .class files'
+class NothingBug4 {
+ public NothingBug4() {
+ scala.Option o = scala.None$.MODULE$;
+ }
+}
diff --git a/test/disabled/run/stream_length.check b/test/disabled/run/stream_length.check
new file mode 100644
index 0000000000..9906de773c
--- /dev/null
+++ b/test/disabled/run/stream_length.check
@@ -0,0 +1 @@
+Length: 970299
diff --git a/test/disabled/run/stream_length.scala b/test/disabled/run/stream_length.scala
new file mode 100644
index 0000000000..68e9cad5ac
--- /dev/null
+++ b/test/disabled/run/stream_length.scala
@@ -0,0 +1,15 @@
+
+
+object Test {
+ def walk(depth: Int, bias: String): Stream[String] = {
+ if (depth == 0)
+ Stream(bias)
+ else {
+ Stream.concat(Stream.range(1, 100).map((x: Int) => walk(depth-1, bias + x)))
+ }
+ }
+
+ def main(args: Array[String]) {
+ println("Length: " + walk(3, "---").length)
+ }
+}
diff --git a/test/disabled/run/t2946/Parsers.scala b/test/disabled/run/t2946/Parsers.scala
new file mode 100644
index 0000000000..c0961034c4
--- /dev/null
+++ b/test/disabled/run/t2946/Parsers.scala
@@ -0,0 +1,4 @@
+class Parser {
+ def parse(t: Any): Unit = {
+ }
+}
diff --git a/test/disabled/run/t2946/ResponseCommon.scala b/test/disabled/run/t2946/ResponseCommon.scala
new file mode 100644
index 0000000000..fa9d8acccb
--- /dev/null
+++ b/test/disabled/run/t2946/ResponseCommon.scala
@@ -0,0 +1,14 @@
+trait ResponseCommon extends Parser {
+ private[this] var paramsParser: Parser = null
+ def withParamsParser(parser: Parser) = {paramsParser = parser; this}
+
+ class Foo {
+ println(paramsParser)
+ }
+
+ override abstract def parse(t: Any): Unit = t match {
+ case ("params", value: List[_]) => value.foreach {paramsParser.parse(_)}
+ case _ => super.parse(t)
+ }
+}
+
diff --git a/test/disabled/run/t2946/Test.scala b/test/disabled/run/t2946/Test.scala
new file mode 100644
index 0000000000..e9d9896a0e
--- /dev/null
+++ b/test/disabled/run/t2946/Test.scala
@@ -0,0 +1,7 @@
+class Test extends Parser with ResponseCommon
+
+object Test {
+ def main(args: Array[String]) {
+ new Test
+ }
+}
diff --git a/test/disabled/scalacheck/redblack.scala b/test/disabled/scalacheck/redblack.scala
new file mode 100644
index 0000000000..0334c1218d
--- /dev/null
+++ b/test/disabled/scalacheck/redblack.scala
@@ -0,0 +1,157 @@
+import org.scalacheck._
+import Prop._
+import Gen._
+
+/*
+Properties of a Red & Black Tree:
+
+A node is either red or black.
+The root is black. (This rule is used in some definitions and not others. Since the
+root can always be changed from red to black but not necessarily vice-versa this
+rule has little effect on analysis.)
+All leaves are black.
+Both children of every red node are black.
+Every simple path from a given node to any of its descendant leaves contains the same number of black nodes.
+*/
+
+abstract class RedBlackTest extends Properties("RedBlack") {
+ object RedBlackTest extends scala.collection.immutable.RedBlack[Int] {
+ def isSmaller(x: Int, y: Int) = x < y
+ }
+
+ import RedBlackTest._
+
+ def rootIsBlack[A](t: Tree[A]) = t.isBlack
+
+ def areAllLeavesBlack[A](t: Tree[A]): Boolean = t match {
+ case Empty => t.isBlack
+ case ne: NonEmpty[_] => List(ne.left, ne.right) forall areAllLeavesBlack
+ }
+
+ def areRedNodeChildrenBlack[A](t: Tree[A]): Boolean = t match {
+ case RedTree(_, _, left, right) => List(left, right) forall (t => t.isBlack && areRedNodeChildrenBlack(t))
+ case BlackTree(_, _, left, right) => List(left, right) forall areRedNodeChildrenBlack
+ case Empty => true
+ }
+
+ def blackNodesToLeaves[A](t: Tree[A]): List[Int] = t match {
+ case Empty => List(1)
+ case BlackTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves map (_ + 1)
+ case RedTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves
+ }
+
+ def areBlackNodesToLeavesEqual[A](t: Tree[A]): Boolean = t match {
+ case Empty => true
+ case ne: NonEmpty[_] =>
+ (
+ blackNodesToLeaves(ne).removeDuplicates.size == 1
+ && areBlackNodesToLeavesEqual(ne.left)
+ && areBlackNodesToLeavesEqual(ne.right)
+ )
+ }
+
+ def orderIsPreserved[A](t: Tree[A]): Boolean = t match {
+ case Empty => true
+ case ne: NonEmpty[_] =>
+ (
+ (ne.left.iterator map (_._1) forall (isSmaller(_, ne.key)))
+ && (ne.right.iterator map (_._1) forall (isSmaller(ne.key, _)))
+ && (List(ne.left, ne.right) forall orderIsPreserved)
+ )
+ }
+
+ def setup(l: List[Int], invariant: Tree[Unit] => Boolean): (Boolean, Tree[Unit])
+
+ def listNoRepetitions(size: Int) = for {
+ s <- Gen.choose(1, size)
+ l <- Gen.listOfN(size, Gen.choose(0, Int.MaxValue)) suchThat (l => l.size == l.removeDuplicates.size)
+ } yield l
+ def listFewRepetitions(size: Int) = for {
+ s <- Gen.choose(1, size)
+ l <- Gen.listOfN(s, Gen.choose(0, size * 4)) suchThat (l => l.size != l.removeDuplicates.size)
+ } yield l
+ def listManyRepetitions(size: Int) = for {
+ s <- Gen.choose(1, size)
+ l <- Gen.listOfN(s, Gen.choose(0, size)) suchThat (l => l.size != l.removeDuplicates.size)
+ } yield l
+ def listEvenRepetitions(size: Int) = listFewRepetitions(size) map (x =>
+ scala.util.Random.shuffle(x zip x flatMap { case (a, b) => List(a, b) })
+ )
+
+ // Arbitrarily weighted list distribution types
+ val seqType: Gen[Int => Gen[List[Int]]]
+
+ def myGen(sized: Int) = for {
+ size <- Gen.choose(0, sized)
+ seq <- seqType
+ list <- seq(size)
+ } yield list
+
+ property("root is black") = forAll(myGen(10)) { l =>
+ setup(l, rootIsBlack)._1 :| setup(l, rootIsBlack)._2.toString
+ }
+ property("all leaves are black") = forAll(myGen(50)) { l =>
+ setup(l, areAllLeavesBlack)._1 :| setup(l, areAllLeavesBlack)._2.toString
+ }
+ property("children of red nodes are black") = forAll(myGen(50)) { l =>
+ setup(l, areRedNodeChildrenBlack)._1 :| setup(l, areRedNodeChildrenBlack)._2.toString
+ }
+ property("Every path from a node to its descendant leaves contains the same number of black nodes") = forAll(myGen(50)) { l =>
+ setup(l, areBlackNodesToLeavesEqual)._1 :| setup(l, areBlackNodesToLeavesEqual)._2.toString
+ }
+ property("Ordering of keys is preserved") = forAll(myGen(50)) { l =>
+ setup(l, orderIsPreserved)._1 :| setup(l, orderIsPreserved)._2.toString
+ }
+}
+
+object TestInsertion extends RedBlackTest {
+ import RedBlackTest._
+ override val seqType = Gen.frequency(
+ (1, listNoRepetitions _),
+ (1, listManyRepetitions _)
+ )
+
+ property("update adds elements") = forAll(myGen(50)) { l =>
+ val tree = l.foldLeft(Empty: Tree[Unit])((acc, n) => acc update (n, ()))
+ forAll(Gen.pick(1, l)) ( n => !(tree lookup n.head isEmpty) :| "Tree: "+tree+" N: "+n.head )
+ }
+
+ override def setup(l: List[Int], invariant: Tree[Unit] => Boolean) = l.foldLeft((true, Empty: Tree[Unit])) {
+ case ((true, acc), n) =>
+ val newRoot = acc update (n, ())
+ (invariant(newRoot), newRoot)
+ case (failed, _) => failed
+ }
+}
+
+object TestDeletion extends RedBlackTest {
+ import RedBlackTest._
+ override val seqType = Gen.frequency(
+ (2, listFewRepetitions _),
+ (3, listManyRepetitions _),
+ (1, listEvenRepetitions _)
+ )
+
+ property("delete removes elements") = forAll(myGen(50)) { l =>
+ val tree = l.foldLeft(Empty: Tree[Unit])((acc, n) => acc update (n, ()))
+ forAll(Gen.choose(1, l.size)) { numberOfElementsToRemove =>
+ forAll(Gen.pick(numberOfElementsToRemove, l)) { elementsToRemove =>
+ val newTree = elementsToRemove.foldLeft(tree)((acc, n) => acc delete n)
+ (elementsToRemove forall (n => newTree lookup n isEmpty)) :| "Tree: "+tree+"New Tree: "+newTree+" Elements to Remove: "+elementsToRemove
+ }
+ }
+ }
+
+ override def setup(l: List[Int], invariant: Tree[Unit] => Boolean) = l.foldLeft((true, Empty: Tree[Unit])) {
+ case ((true, acc), n) =>
+ val newRoot = if (acc lookup n isEmpty) acc update (n, ()) else acc delete n
+ (invariant(newRoot), newRoot)
+ case (failed, _) => failed
+ }
+}
+
+object Test extends Properties("RedBlack") {
+ include(TestInsertion)
+ include(TestDeletion)
+}
+