diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-09 03:53:41 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-09 03:53:41 +0000 |
commit | 2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2 (patch) | |
tree | 9bb2044c595fe260c352a00cf98bb2ecece50437 /test/disabled/run | |
parent | f7ab13b08e085c3bf94d857fc9648ee724e4cb08 (diff) | |
download | scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.tar.gz scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.tar.bz2 scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.zip |
Organized disabled directory so it works with p...
Organized disabled directory so it works with partest. You can run
./partest --srcpath disabled to run the tests in that location. Fixed a
few tests in disabled and pending and moved to files.
Diffstat (limited to 'test/disabled/run')
-rw-r--r-- | test/disabled/run/collection-stacks.check | 14 | ||||
-rw-r--r-- | test/disabled/run/collection-stacks.scala | 38 | ||||
-rw-r--r-- | test/disabled/run/deeps.check | 83 | ||||
-rw-r--r-- | test/disabled/run/deeps.scala | 112 | ||||
-rw-r--r-- | test/disabled/run/forvaleq.check | 5 | ||||
-rw-r--r-- | test/disabled/run/forvaleq.scala | 92 | ||||
-rw-r--r-- | test/disabled/run/iq.check | 12 | ||||
-rw-r--r-- | test/disabled/run/iq.scala | 100 | ||||
-rw-r--r-- | test/disabled/run/t0485.check | 32 | ||||
-rw-r--r-- | test/disabled/run/t0485.scala | 54 | ||||
-rw-r--r-- | test/disabled/run/unittest_collection.scala | 103 |
11 files changed, 645 insertions, 0 deletions
diff --git a/test/disabled/run/collection-stacks.check b/test/disabled/run/collection-stacks.check new file mode 100644 index 0000000000..fcb39c460c --- /dev/null +++ b/test/disabled/run/collection-stacks.check @@ -0,0 +1,14 @@ +1-2-3: true +1-2-3: true +apply +1: true +1: true +3: true +3: true +top +3: true +3: true +pop +1-2: true +3: true +1-2: true diff --git a/test/disabled/run/collection-stacks.scala b/test/disabled/run/collection-stacks.scala new file mode 100644 index 0000000000..665fb91e13 --- /dev/null +++ b/test/disabled/run/collection-stacks.scala @@ -0,0 +1,38 @@ +import scala.collection._ + +object Test extends Application { + def mutableStack[T](xs: T*): mutable.Stack[T] = { + val s = new mutable.Stack[T] + s.pushAll(xs) + s + } + + def immutableStack[T](xs: T*): immutable.Stack[T] = { + immutable.Stack.Empty pushAll xs + } + + def check[T](expected: T, got: T) { + println(got + ": " + (expected == got)) + } + + // check #957 + check("1-2-3", immutableStack(1, 2, 3).elements.mkString("-")) + check("1-2-3", mutableStack(1, 2, 3).elements.mkString("-")) + + println("apply") + check(1, immutableStack(1, 2, 3).apply(0)) + check(1, mutableStack(1, 2, 3).apply(0)) + check(3, immutableStack(1, 2, 3).apply(2)) + check(3, mutableStack(1, 2, 3).apply(2)) + + println("top") + check(3, immutableStack(1, 2, 3).top) + check(3, mutableStack(1, 2, 3).top) + + println("pop") + check("1-2", immutableStack(1, 2, 3).pop.mkString("-")) + check(3, mutableStack(1, 2, 3).pop()) + check("1-2", { val s = mutableStack(1, 2, 3); s.pop(); s.toList.mkString("-") }) +} + +// vim: set ts=2 sw=2 et: diff --git a/test/disabled/run/deeps.check b/test/disabled/run/deeps.check new file mode 100644 index 0000000000..f1925fcbc1 --- /dev/null +++ b/test/disabled/run/deeps.check @@ -0,0 +1,83 @@ +false +false +true + +false +false +true + +x=Array(1) +y=Array(1) +false +false +true + +x=Array(Array(1), Array(1)) +y=Array(Array(1), Array(1)) +false +false +true + +x=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +y=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +false +false +true + +false +false +true +false +false +true +Array(true, false) +Array(true, false) +[true;false] +true;false + +Array([Z@0000000, [Z@0000000) +Array(Array(true, false), Array(true, false)) +[[true;false];[true;false]] +true;false;true;false + +Array([[Z@0000000, [[Z@0000000) +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +[[[true;false];[true;false]];[[true;false];[true;false]]] +true;false;true;false;true;false;true;false + +Array(1.0, 0.0) +Array(1.0, 0.0) +[1.0;0.0] +1.0;0.0 + +Array([D@0000000, [D@0000000) +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +[[1.0;0.0];[1.0;0.0]] +1.0;0.0;1.0;0.0 + +Array([[D@0000000, [[D@0000000) +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +[[[1.0;0.0];[1.0;0.0]];[[1.0;0.0];[1.0;0.0]]] +1.0;0.0;1.0;0.0;1.0;0.0;1.0;0.0 + +Array(a, b) +Array(a, b) +[a;b] +a;b + +Array([Ljava.lang.String;@0000000, [Ljava.lang.String;@0000000) +Array(Array(a, b), Array(a, b)) +[[a;b];[a;b]] +a;b;a;b + +Array([[Ljava.lang.String;@0000000, [[Ljava.lang.String;@0000000) +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +[[[a;b];[a;b]];[[a;b];[a;b]]] +a;b;a;b;a;b;a;b + +[[true; false]; [false]] +[[1; 2]; [3]] +[[1; 2]; [3]] + +Array(boo, and, foo) +Array(a) diff --git a/test/disabled/run/deeps.scala b/test/disabled/run/deeps.scala new file mode 100644 index 0000000000..662008f3f3 --- /dev/null +++ b/test/disabled/run/deeps.scala @@ -0,0 +1,112 @@ +//############################################################################ +// deepEquals / deepToString +//############################################################################ +// $Id: $ + +//############################################################################ +// need to revisit array equqality +object Test extends Application { + + def testEquals1 { + println(Array(1) == Array(1)) + println(Array(1) equals Array(1)) + println(Array(1) deepEquals Array(1)) + println + } + + def testEquals2 { + println(Array(Array(1), Array(2)) == Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)) equals Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)) deepEquals Array(Array(1), Array(2))) + println + } + + def testEquals3 { + val a1 = Array(1) + val b1 = Array(1) + val a2 = Array(a1, b1) + val b2 = Array(a1, b1) + val a3 = Array(a2, b2) + val b3 = Array(a2, b2) + def test[T](x: Array[T], y: Array[T]) { + println("x=" + x.deepToString) + println("y=" + y.deepToString) + println(x == y) + println(x equals y) + println(x deepEquals y) + println + } + test(a1, b1) + test(a2, b2) + test(a3, b3) + } + + def testEquals4 { + println("boo:and:foo".split(':') == "boo:and:foo".split(':')) + println("boo:and:foo".split(':') equals "boo:and:foo".split(':')) + println("boo:and:foo".split(':') deepEquals "boo:and:foo".split(':')) + + val xs = new java.util.ArrayList[String](); xs.add("a") + val ys = new java.util.ArrayList[String](); ys.add("a") + println(xs.toArray == ys.toArray) + println(xs.toArray equals ys.toArray) + println(xs.toArray deepEquals ys.toArray) + } + + def testToString1 { + def sweep(s: String) = + s.replaceAll("D@[0-9a-fA-F]+", "D@0000000") + .replaceAll("Z@[0-9a-fA-F]+", "Z@0000000") + .replaceAll(";@[0-9a-fA-F]+", ";@0000000") + def test[T](a: Array[T]) { + println(sweep(a.toString)) + println(a.deepToString) + println(a.deepMkString("[", ";", "]")) + println(a.deepMkString(";")) + println + } + + val ba1 = Array(true, false) + val ba2 = Array(ba1, ba1) + val ba3 = Array(ba2, ba2) + test(ba1) + test(ba2) + test(ba3) + + val da1 = Array(1.0d, 0.0d) + val da2 = Array(da1, da1) + val da3 = Array(da2, da2) + test(da1) + test(da2) + test(da3) + + val sa1 = Array("a", "b") + val sa2 = Array(sa1, sa1) + val sa3 = Array(sa2, sa2) + test(sa1) + test(sa2) + test(sa3) + } + + def testToString2 { + println(Array(Array(true, false), Array(false)).deepMkString("[", "; ", "]")) + println(Array(Array('1', '2'), Array('3')).deepMkString("[", "; ", "]")) + println(Array(Array(1, 2), Array(3)).deepMkString("[", "; ", "]")) + println + } + + def testToString3 { + println("boo:and:foo".split(':').deepToString) + + val xs = new java.util.ArrayList[String](); xs.add("a") + println(xs.toArray.deepToString) + } + + testEquals1 + testEquals2 + testEquals3 + testEquals4 + testToString1 + testToString2 + testToString3 +} diff --git a/test/disabled/run/forvaleq.check b/test/disabled/run/forvaleq.check new file mode 100644 index 0000000000..ec57719cb4 --- /dev/null +++ b/test/disabled/run/forvaleq.check @@ -0,0 +1,5 @@ +List(2, 6, 10, 14, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38) +List(2, 6, 10, 14, 18, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2) +List(2, 6, 10, 14, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38) +List(2, 6, 10, 14, 18, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2) +called 20 times diff --git a/test/disabled/run/forvaleq.scala b/test/disabled/run/forvaleq.scala new file mode 100644 index 0000000000..1e4fd33dbc --- /dev/null +++ b/test/disabled/run/forvaleq.scala @@ -0,0 +1,92 @@ +// test "foo = expr" clauses in for comprehensions +// $Id$ + +import scala.collection.immutable.Queue +import scala.{List=>L} + +object Test { + // redefine some symbols to make it extra hard + class List + class Tuple2 + def List[A](as: A*) = 5 + + def firstDigit(x: Int): Int = + x match { + case 0 => 0 + case _ if (x<0) => firstDigit(-x) + case _ if (x<10) => x + case _ => firstDigit(x / 10) + } + + + { + // a basic test case + + val input = L.range(0,20) + val oddFirstTimesTwo = + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} + yield x*2 + println(oddFirstTimesTwo) + } + + { + // a test case with patterns + + val input = L.range(0, 20) + val oddFirstTimesTwo = + for {x <- input + xf = firstDigit(x) + yf = x - firstDigit(x) / 10 + (a, b) = (xf - yf, xf + yf) + if xf % 2 == 1} + yield a + b + println(oddFirstTimesTwo) + } + + { + // make sure it works on non-Ls + + // val input: Queue = Queue.Empty[int].incl(L.range(0,20)) + val input = L.range(0, 20).elements + val oddFirstTimesTwo = + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} + yield x*2 + println(oddFirstTimesTwo.toList) + } + + { + // yield the computed value + + val input = L.range(0,20) + val oddFirstTimesTwo = + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} + yield xf*2 + println(oddFirstTimesTwo) + } + + { + // make sure the function is only called once + var count: Int = 0 + + def fdct(x: Int) = { + count += 1 + firstDigit(x) + } + + val input = L.range(0,20) + for {x <- input + xf = fdct(x) + if xf % 2 == 1} + yield xf + + println("called " + count + " times") + } + + def main(args: Array[String]) {} +} diff --git a/test/disabled/run/iq.check b/test/disabled/run/iq.check new file mode 100644 index 0000000000..81114ea181 --- /dev/null +++ b/test/disabled/run/iq.check @@ -0,0 +1,12 @@ +Empty +Head: 42 +q5: Queue(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) +q5[5]: 5 +q5 == q5c: true +q5c == q5: true +q8: Queue(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) +q8 == q9: true +Elements: 1 2 3 4 5 6 7 8 9 +String: <1-2-3-4-5-6-7-8-9> +Length: 9 +Front: 1 diff --git a/test/disabled/run/iq.scala b/test/disabled/run/iq.scala new file mode 100644 index 0000000000..8ae3dbb080 --- /dev/null +++ b/test/disabled/run/iq.scala @@ -0,0 +1,100 @@ +/* $Id$ + * Test file for immutable queues. + */ + +import scala.collection.immutable.Queue + +object iq { + def main { + /* Create an empty queue. */ + val q: Queue[Int] = Queue.Empty + + /* Test isEmpty. + * Expected: Empty + */ + if (q.isEmpty) { + Console.println("Empty") + } + + /* Test infix enqueing. */ + //val q2 = q + 42 + 0 // deprecated + val q2 = q.enqueue(42).enqueue(0) + + /* Test is empty and dequeue. + * Expected: Head: 42 + */ + val q4 = + if (q2.isEmpty) { + Console.println("Empty") + q2 + } + else { + val (head, q3) = q2.dequeue + Console.println("Head: " + head) + q3 + } + + /* Test sequence enqueing. */ + val q5: Queue[Any] = q4.enqueue(List(1,2,3,4,5,6,7,8,9)) + /* Test toString. + * Expected: Head: q5: Queue(0,1,2,3,4,5,6,7,8,9) + */ + Console.println("q5: " + q5) + /* Test apply + * Expected: q5[5]: 5 + */ + Console.println("q5[5]: " + q5(5)) + + val q5c: Queue[Int] = Queue.Empty.enqueue(List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) + + /* Testing == + * Expected: q5 == q9: true + * q9 == q5: true + */ + Console.println("q5 == q5c: " + (q5 == q5c)) + Console.println("q5c == q5: " + (q5c == q5)) + + val (_, q6) = q5.dequeue + val (_, q7) = q6.dequeue + //val q8 = q7 + 10 + 11 //deprecated + val q8 = q7.enqueue(10).enqueue(11) + /* Test dequeu + * Expected: q8: Queue(2,3,4,5,6,7,8,9,10,11) + */ + Console.println("q8: " + q8) + val q9 = new Queue(2,3,4,5,6,7,8,9,10,11) + + /* Testing == + * Expected: q8 == q9: true + */ + Console.println("q8 == q9: " + (q8 == q9)) + + /* Testing elements + * Expected: Elements: 1 2 3 4 5 6 7 8 9 + */ + Console.print("Elements: "); + q6.elements.foreach(e => Console.print(" "+ e + " ")) + Console.println; + + /* Testing mkString + * Expected: String: <1-2-3-4-5-6-7-8-9> + */ + Console.println("String: " + q6.mkString("<","-",">")) + + /* Testing length + * Expected: Length: 9 + */ + Console.println("Length: " + q6.length) + + /* Testing front + * Expected: Front: 1 + */ + Console.println("Front: " + q6.front); + } +} + +object Test { + def main(args: Array[String]) { + iq.main + } +} diff --git a/test/disabled/run/t0485.check b/test/disabled/run/t0485.check new file mode 100644 index 0000000000..3a462cfdc1 --- /dev/null +++ b/test/disabled/run/t0485.check @@ -0,0 +1,32 @@ +m1={(10,20), (20,30)} +m2={(10,20)} +m1.size > m2.size is true +m1 equals m2 is true + +m1={(10,20), (20,30)} +m2={(10,20)} +m1.size > m2.size is true +m1 equals m2 is true + +m1={(10,20), (20,30)} +m2={(10,20)} +m1.size > m2.size is true +m1 equals m2 is true + +java.lang.CloneNotSupportedException: The underlying map doesn't implement the Cloneable interface + +s1=[10, 20] +s2=[10] +s1.size > s2 is true +s1 equals s2 is true + +s1=[10, 20] +s2=[10] +s1.size > s2 is true +s1 equals s2 is true + +s1=[10, 20] +s2=[10] +s1.size > s2 is true +s1 equals s2 is true + diff --git a/test/disabled/run/t0485.scala b/test/disabled/run/t0485.scala new file mode 100644 index 0000000000..9e2017aacc --- /dev/null +++ b/test/disabled/run/t0485.scala @@ -0,0 +1,54 @@ +import scala.collection.jcl + +object Test extends Application { + testMap + testSet +} + +object testMap { + def toString(m1: collection.Map[Int, Int]): String = + m1.toList.sort((x, y) => x < y).mkString("{", ", ", "}") + def test(m1: jcl.Map[Int, Int]) { + try { + m1.put(10, 20) + val m2 = m1.clone() + m1.put(20, 30) + println("m1="+toString(m1)) + println("m2="+toString(m2)) + println("m1.size > m2.size is "+ (m1.size > m2.size)) + m1.remove((20, 30)) + println("m1 equals m2 is "+ (m1 equals m2)) + println() + } + catch { + case e: Exception => + println(e); println() + } + } + test(new jcl.HashMap[Int, Int]) + // Clone on IdentityHashMap of java-ibm-1.6 behaves differently than all others + // Therefore, for now we will not perform this test on it. + // test(new jcl.IdentityHashMap[Int, Int]) + test(new jcl.LinkedHashMap[Int, Int]) + test(new jcl.TreeMap[Int, Int]) + test(new jcl.WeakHashMap[Int, Int]) +} + +object testSet { + def toString(s1: collection.Set[Int]): String = + s1.toList.sort((x, y) => x < y).mkString("[", ", ", "]") + def test(s1: jcl.Set[Int]) { + s1.add(10) + val s2 = s1.clone() + s1.add(20) + println("s1="+toString(s1)) + println("s2="+toString(s2)) + println("s1.size > s2 is "+ (s1.size > s2.size)) + s1.remove(20) + println("s1 equals s2 is "+ (s1 equals s2)) + println() + } + test(new jcl.HashSet[Int]) + test(new jcl.LinkedHashSet[Int]) + test(new jcl.TreeSet[Int]) +} diff --git a/test/disabled/run/unittest_collection.scala b/test/disabled/run/unittest_collection.scala new file mode 100644 index 0000000000..5d7ab97425 --- /dev/null +++ b/test/disabled/run/unittest_collection.scala @@ -0,0 +1,103 @@ + +object Test { + + import scala.testing.SUnit._ + import scala.collection.mutable.{ArrayBuffer, Buffer, BufferProxy, ListBuffer} + + trait BufferTest extends Assert { + def doTest(x:Buffer[String]) = { + // testing method += + x += "one" + assertEquals("retrieving 'one'", x(0), "one") + assertEquals("length A ", x.length, 1) + x += "two" + assertEquals("retrieving 'two'", x(1), "two") + assertEquals("length B ", x.length, 2) + + // testing method -= (removing last element) + x -= "two" + + assertEquals("length C ", x.length, 1) + + try { x(1); fail("no exception for removed element") } + catch { case i:IndexOutOfBoundsException => } + + try { x.remove(1); fail("no exception for removed element") } + catch { case i:IndexOutOfBoundsException => } + + x += "two2" + assertEquals("length D ", x.length, 2) + + // removing first element + x.remove(0) + assertEquals("length E ", x.length, 1) + + // toList + assertEquals("toList ", x.toList, List("two2")) + + // clear + x.clear + assertEquals("length F ", x.length, 0) + + // copyToBuffer + x += "a" + x += "b" + val dest = new ArrayBuffer[String] + x copyToBuffer dest + assertEquals("dest", List("a", "b"), dest.toList) + assertEquals("source", List("a", "b"), x.toList) + } + } + + class TArrayBuffer extends TestCase("collection.mutable.ArrayBuffer") with Assert with BufferTest { + + var x: ArrayBuffer[String] = _ + + override def runTest = { setUp; doTest(x); tearDown } + + override def setUp = { x = new scala.collection.mutable.ArrayBuffer } + + override def tearDown = { x.clear; x = null } + } + + class TListBuffer extends TestCase("collection.mutable.ListBuffer") with Assert with BufferTest { + + var x: ListBuffer[String] = _ + + override def runTest = { setUp; doTest(x); tearDown } + + override def setUp = { x = new scala.collection.mutable.ListBuffer } + + override def tearDown = { x.clear; x = null } + + } + + class TBufferProxy extends TestCase("collection.mutable.BufferProxy") with Assert with BufferTest { + + class BBuf(z:ListBuffer[String]) extends BufferProxy[String] { + def self = z + } + + var x: BufferProxy[String] = _ + + override def runTest = { setUp; doTest(x); tearDown } + + override def setUp = { x = new BBuf(new scala.collection.mutable.ListBuffer) } + + override def tearDown = { x.clear; x = null } + + } + + def main(args:Array[String]) = { + val ts = new TestSuite( + //new TArrayBuffer, + new TListBuffer//, + //new TBufferProxy + ) + val tr = new TestResult() + ts.run(tr) + for(val failure <- tr.failures) { + Console.println(failure) + } + } +} |