summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-10-01 07:12:25 -0700
committerPaul Phillips <paulp@improving.org>2012-10-01 07:15:29 -0700
commit81226b82d8c8b138eabb6956cab82410a17d812c (patch)
tree274f69cabfe3158818952d3ac15b99e4137fcb04
parentd2074796a8b822c4c82faecc8eb0eef4837508e3 (diff)
downloadscala-81226b82d8c8b138eabb6956cab82410a17d812c.tar.gz
scala-81226b82d8c8b138eabb6956cab82410a17d812c.tar.bz2
scala-81226b82d8c8b138eabb6956cab82410a17d812c.zip
Recovered a bunch of deleted tests.
Are we in the habit of simply deleting tests when they become inconvenient? A comment referenced test "0851" as the example of why the code was needed; the test was deleted years ago for no reason I can see except that it was not passing at the time. Words fail me. Public Service Announcement: tests which are failing are the MOST USEFUL tests. DON'T DELETE THEM!
-rw-r--r--test/files/pos/t0851.scala14
-rw-r--r--test/files/pos/t0872.scala8
-rw-r--r--test/files/run/collection-stacks.check14
-rw-r--r--test/files/run/collection-stacks.scala38
-rw-r--r--test/files/run/deeps.check87
-rw-r--r--test/files/run/deeps.scala114
6 files changed, 275 insertions, 0 deletions
diff --git a/test/files/pos/t0851.scala b/test/files/pos/t0851.scala
new file mode 100644
index 0000000000..fc7109dcd4
--- /dev/null
+++ b/test/files/pos/t0851.scala
@@ -0,0 +1,14 @@
+package test
+
+object test1 {
+ case class Foo[T,T2](f : (T,T2) => String) extends (((T,T2)) => String){
+ def apply(t : T) = (s:T2) => f(t,s)
+ def apply(p : (T,T2)) = f(p._1,p._2)
+ }
+ implicit def g[T](f : (T,String) => String) = Foo(f)
+ def main(args : Array[String]) : Unit = {
+ val f = (x:Int,s:String) => s + x
+ println(f(1))
+ ()
+ }
+}
diff --git a/test/files/pos/t0872.scala b/test/files/pos/t0872.scala
new file mode 100644
index 0000000000..8f4c1c4436
--- /dev/null
+++ b/test/files/pos/t0872.scala
@@ -0,0 +1,8 @@
+object Main {
+ def main(args : Array[String]) {
+ val fn = (a : Int, str : String) => "a: " + a + ", str: " + str
+ implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null)
+ println(fn(1))
+ ()
+ }
+}
diff --git a/test/files/run/collection-stacks.check b/test/files/run/collection-stacks.check
new file mode 100644
index 0000000000..aa25cd1fa6
--- /dev/null
+++ b/test/files/run/collection-stacks.check
@@ -0,0 +1,14 @@
+3-2-1: true
+3-2-1: true
+apply
+3: true
+3: true
+1: true
+1: true
+top
+3: true
+3: true
+pop
+2-1: true
+3: true
+2-1: true
diff --git a/test/files/run/collection-stacks.scala b/test/files/run/collection-stacks.scala
new file mode 100644
index 0000000000..fbee3f8594
--- /dev/null
+++ b/test/files/run/collection-stacks.scala
@@ -0,0 +1,38 @@
+import scala.collection.{ immutable, mutable }
+
+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[T] pushAll xs
+ }
+
+ def check[T](expected: T, got: T) {
+ println(got + ": " + (expected == got))
+ }
+
+ // check #957
+ check("3-2-1", immutableStack(1, 2, 3).iterator.mkString("-"))
+ check("3-2-1", mutableStack(1, 2, 3).iterator.mkString("-"))
+
+ println("apply")
+ check(3, immutableStack(1, 2, 3).apply(0))
+ check(3, mutableStack(1, 2, 3).apply(0))
+ check(1, immutableStack(1, 2, 3).apply(2))
+ check(1, 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("2-1", immutableStack(1, 2, 3).pop.mkString("-"))
+ check(3, mutableStack(1, 2, 3).pop())
+ check("2-1", { val s = mutableStack(1, 2, 3); s.pop(); s.toList.mkString("-") })
+}
+
+// vim: set ts=2 sw=2 et:
diff --git a/test/files/run/deeps.check b/test/files/run/deeps.check
new file mode 100644
index 0000000000..a68e474f62
--- /dev/null
+++ b/test/files/run/deeps.check
@@ -0,0 +1,87 @@
+testEquals1
+false
+false
+true
+
+testEquals2
+false
+false
+true
+
+testEquals3
+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
+
+testEquals4
+false
+false
+true
+false
+false
+true
+Array(true, false)
+Array(true, false)
+[true;false]
+true;false
+
+Array(Array(true, false), Array(true, false))
+Array(Array(true, false), Array(true, false))
+[Array(true, false);Array(true, false)]
+Array(true, false);Array(true, false)
+
+Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false)))
+Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false)))
+[Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false))]
+Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false))
+
+Array(1.0, 0.0)
+Array(1.0, 0.0)
+[1.0;0.0]
+1.0;0.0
+
+Array(Array(1.0, 0.0), Array(1.0, 0.0))
+Array(Array(1.0, 0.0), Array(1.0, 0.0))
+[Array(1.0, 0.0);Array(1.0, 0.0)]
+Array(1.0, 0.0);Array(1.0, 0.0)
+
+Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0)))
+Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0)))
+[Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0))]
+Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0))
+
+Array(a, b)
+Array(a, b)
+[a;b]
+a;b
+
+Array(Array(a, b), Array(a, b))
+Array(Array(a, b), Array(a, b))
+[Array(a, b);Array(a, b)]
+Array(a, b);Array(a, b)
+
+Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b)))
+Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b)))
+[Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b))]
+Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b))
+
+[Array(true, false); Array(false)]
+[Array(1, 2); Array(3)]
+[Array(1, 2); Array(3)]
+
+Array(boo, and, foo)
+Array(a)
diff --git a/test/files/run/deeps.scala b/test/files/run/deeps.scala
new file mode 100644
index 0000000000..6049cc6024
--- /dev/null
+++ b/test/files/run/deeps.scala
@@ -0,0 +1,114 @@
+//############################################################################
+// deepEquals / deep.toString
+//############################################################################
+
+//############################################################################
+// need to revisit array equqality
+object Test {
+
+ def testEquals1 {
+ println(Array(1) == Array(1))
+ println(Array(1) equals Array(1))
+ println(Array(1).deep == Array(1).deep)
+ 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)).deep equals Array(Array(1), Array(2)).deep)
+ 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.deep.toString)
+ println("y=" + y.deep.toString)
+ println(x == y)
+ println(x equals y)
+ println(x.deep == y.deep)
+ 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(':').deep == "boo:and:foo".split(':').deep)
+
+ 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.deep == ys.toArray.deep)
+ }
+
+ 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.deep.toString))
+ println(a.deep.toString)
+ println(a.deep.mkString("[", ";", "]"))
+ println(a.deep.mkString(";"))
+ 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)).deep.mkString("[", "; ", "]"))
+ println(Array(Array('1', '2'), Array('3')).deep.mkString("[", "; ", "]"))
+ println(Array(Array(1, 2), Array(3)).deep.mkString("[", "; ", "]"))
+ println
+ }
+
+ def testToString3 {
+ println("boo:and:foo".split(':').deep.toString)
+
+ val xs = new java.util.ArrayList[String](); xs.add("a")
+ println(xs.toArray.deep.toString)
+ }
+
+ def main(args: Array[String]): Unit = {
+ println("testEquals1") ; testEquals1
+ println("testEquals2") ; testEquals2
+ println("testEquals3") ; testEquals3
+ println("testEquals4") ; testEquals4
+ testToString1
+ testToString2
+ testToString3
+ }
+}