From 0ef0f40ae31bf8a1e3d5b9c6eea7ef5b5a073192 Mon Sep 17 00:00:00 2001 From: Burak Emir Date: Wed, 24 Jan 2007 15:20:25 +0000 Subject: moved working tests to files --- test/pending/pos/bug402.scala | 7 --- test/pending/pos/bug419.scala | 11 ---- test/pending/pos/bug430.scala | 20 ------- test/pending/pos/bug443.scala | 14 ----- test/pending/pos/bug796.scala | 26 -------- test/pending/pos/gosh.scala | 44 -------------- test/pending/pos/init.scala | 14 ----- test/pending/pos/unapplyComplex.scala | 37 ------------ test/pending/pos/unapplyContexts2.scala | 11 ---- test/pending/pos/unapplyGeneric.scala | 11 ---- test/pending/pos/unapplyNeedsMemberType.scala | 25 -------- test/pending/pos/unapplySeq.scala | 26 -------- test/pending/run/bug405.scala | 5 -- test/pending/run/retclosure.scala | 23 ------- test/pending/run/unapply.scala | 86 --------------------------- 15 files changed, 360 deletions(-) delete mode 100644 test/pending/pos/bug402.scala delete mode 100644 test/pending/pos/bug419.scala delete mode 100644 test/pending/pos/bug430.scala delete mode 100644 test/pending/pos/bug443.scala delete mode 100644 test/pending/pos/bug796.scala delete mode 100644 test/pending/pos/gosh.scala delete mode 100644 test/pending/pos/init.scala delete mode 100644 test/pending/pos/unapplyComplex.scala delete mode 100644 test/pending/pos/unapplyContexts2.scala delete mode 100644 test/pending/pos/unapplyGeneric.scala delete mode 100644 test/pending/pos/unapplyNeedsMemberType.scala delete mode 100644 test/pending/pos/unapplySeq.scala delete mode 100644 test/pending/run/bug405.scala delete mode 100644 test/pending/run/retclosure.scala delete mode 100644 test/pending/run/unapply.scala (limited to 'test/pending') diff --git a/test/pending/pos/bug402.scala b/test/pending/pos/bug402.scala deleted file mode 100644 index a5a3df4825..0000000000 --- a/test/pending/pos/bug402.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Main { - def main(args: Array[String]): Unit = { - val x: Any = 2 - System.out.println((0.5).isInstanceOf[Int]); - System.out.println(x.isInstanceOf[Int]); - } -} diff --git a/test/pending/pos/bug419.scala b/test/pending/pos/bug419.scala deleted file mode 100644 index 65dcb04356..0000000000 --- a/test/pending/pos/bug419.scala +++ /dev/null @@ -1,11 +0,0 @@ -trait Bar { - class Config {} - var config: Config; // aha, traits can have variables? -} - -object Foo extends Bar { - - class FooConfig extends Config; - var config: Config = new FooConfig() // or not - -} diff --git a/test/pending/pos/bug430.scala b/test/pending/pos/bug430.scala deleted file mode 100644 index 7e3e7eaaec..0000000000 --- a/test/pending/pos/bug430.scala +++ /dev/null @@ -1,20 +0,0 @@ -object Test extends Application { - def foo[T <% Ordered[T]](x: T): Unit = System.out.println(""+(x < x)+" "+(x <= x)) - def bar(x: Unit ): Unit = foo(x); - def bar(x: Boolean): Unit = foo(x); - def bar(x: Byte ): Unit = foo(x); - def bar(x: Short ): Unit = foo(x); - def bar(x: Int ): Unit = foo(x); - def bar(x: Long ): Unit = foo(x); - def bar(x: Float ): Unit = foo(x); - def bar(x: Double ): Unit = foo(x); - bar(()) - bar(true) - bar(1: byte) - bar(1: short) - bar('a') - bar(1) - bar(1l) - bar(1.0f) - bar(1.0) -} diff --git a/test/pending/pos/bug443.scala b/test/pending/pos/bug443.scala deleted file mode 100644 index 5b83e9d2cb..0000000000 --- a/test/pending/pos/bug443.scala +++ /dev/null @@ -1,14 +0,0 @@ -object Test { - - def lookup(): Option[Pair[String, String]] = - (null: Option[Pair[String, String]]) match { - case Some(Pair(_, _)) => - if (true) - Some(Pair(null, null)) - else - lookup() match { - case Some(_) => Some(null) - case None => None - } - } -} diff --git a/test/pending/pos/bug796.scala b/test/pending/pos/bug796.scala deleted file mode 100644 index 756c103e7c..0000000000 --- a/test/pending/pos/bug796.scala +++ /dev/null @@ -1,26 +0,0 @@ -/** I know what I am doing is wrong -- since I am about to look into - * this bug, I add a test in pending/pos... however, I am afraid that - * once this bug is fixed, this test case might go into test/pos - * there it adds to the huge number of tiny little test cases. - * - * Ideally, an option in the bugtracking system would automatically - * handle "pos" bugs. - */ -object Test extends Application { - - object Twice { - def apply(x: int) = x * 2 - def unapply(x: int): Option[Tuple1[int]] = - if (x % 2 == 0) Some(Tuple1(x / 2)) - else None - } - - def test(x: int) = x match { - case Twice(y) => "x is two times "+y - case _ => "x is odd" - } - - Console.println(test(3)) - Console.println(test(4)) - -} diff --git a/test/pending/pos/gosh.scala b/test/pending/pos/gosh.scala deleted file mode 100644 index c4cd3df80b..0000000000 --- a/test/pending/pos/gosh.scala +++ /dev/null @@ -1,44 +0,0 @@ -object ShapeTest extends Application { - - class Point(x : int, y : int) { - override def toString() = "[" + x + "," + y + "]" - } - - abstract class Shape { - def draw() : unit - } - - class Line(s : Point, e : Point) extends Shape { - def draw() : unit = { Console.println("draw line " + s + "," + e) } - } - - abstract class Foo { - type T <: Object - - def show(o : T) : unit - def print() : unit = {Console.println("in Foo")} - } - - abstract class ShapeFoo extends Foo { - type T <: Shape - def show(o : T) : unit = { o.draw() } - override def print() : unit = {Console.println("in ShapeFoo")} - } - - class LineFoo extends ShapeFoo { - type T = Line - override def print() : unit = {Console.println("in LineFoo")} - } - - val p1 = new Point(1,4) - val p2 = new Point(12, 28) - - val l1 = new Line(p1, p2) - - - val l = new ShapeFoo{ // ** // - type T = Line // ** // - override def print() : unit = {Console.println("in LineFoo")} // ** // - } - l.show(l1) // ** // -} diff --git a/test/pending/pos/init.scala b/test/pending/pos/init.scala deleted file mode 100644 index c51446c804..0000000000 --- a/test/pending/pos/init.scala +++ /dev/null @@ -1,14 +0,0 @@ -class Foo { - - var cnt = 0 - - class Bar { - cnt = cnt + 1 - val id = cnt - } -} - -object Test extends Application { - val foo = new Foo - Console.println((new foo.Bar).id) -} diff --git a/test/pending/pos/unapplyComplex.scala b/test/pending/pos/unapplyComplex.scala deleted file mode 100644 index 54080eb86f..0000000000 --- a/test/pending/pos/unapplyComplex.scala +++ /dev/null @@ -1,37 +0,0 @@ -trait Complex extends Product2[double,double] - -class ComplexRect(val _1:double, val _2:double) extends Complex { - override def toString = "ComplexRect("+_1+","+_2+")" -} - -class ComplexPolar(val _1:double, val _2:double) extends Complex { - override def toString = "ComplexPolar("+_1+","+_2+")" -} - -object ComplexRect { - def unapply(z:Complex): Option[Complex] = { - if(z.isInstanceOf[ComplexRect]) Some(z) else z match { - case ComplexPolar(mod, arg) => - Some(new ComplexRect(mod*Math.cos(arg), mod*Math.sin(arg))) -} } } - -object ComplexPolar { - def unapply(z:Complex): Option[Complex] = { - if(z.isInstanceOf[ComplexPolar]) Some(z) else z match { - case ComplexRect(re,im) => - Some(new ComplexPolar(Math.sqrt(re*re + im*im), Math.atan(re/im))) -} } } - -object Test { - def main(args:Array[String]) = { - new ComplexRect(1,1) match { - case ComplexPolar(mod,arg) => // z @ ??? - Console.println("mod"+mod+"arg"+arg) - } - val Komplex = ComplexRect - new ComplexPolar(Math.sqrt(2),Math.Pi / 4.0) match { - case Komplex(re,im) => // z @ ??? - Console.println("re"+re+" im"+im) - } - } -} diff --git a/test/pending/pos/unapplyContexts2.scala b/test/pending/pos/unapplyContexts2.scala deleted file mode 100644 index fcf1e2ff62..0000000000 --- a/test/pending/pos/unapplyContexts2.scala +++ /dev/null @@ -1,11 +0,0 @@ -trait Analyzer { - val WILDCARD = "23" -} - -trait Contexts2 requires Analyzer { - class Context { - def collect(sels: List[String]): List[String] = sels match { - case List(WILDCARD) => val dummy = WILDCARD; Nil - } - } -} diff --git a/test/pending/pos/unapplyGeneric.scala b/test/pending/pos/unapplyGeneric.scala deleted file mode 100644 index bf88816885..0000000000 --- a/test/pending/pos/unapplyGeneric.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Bar { - def unapply[A,B](bar:Bar[A,B]) = Some(bar) -} - -class Bar[A,B](val _1:A, val _2:B) extends Product2[A,B] - -object Test { - new Bar(2, 'a') match { - case Bar(x,y) => - } -} diff --git a/test/pending/pos/unapplyNeedsMemberType.scala b/test/pending/pos/unapplyNeedsMemberType.scala deleted file mode 100644 index b423257e04..0000000000 --- a/test/pending/pos/unapplyNeedsMemberType.scala +++ /dev/null @@ -1,25 +0,0 @@ -// error with -Xunapply, (because of missing call to memberType?) - -trait Gunk[a] { - - type Seq - - object Cons { - def unapply(s: Seq) = unapply_Cons(s) - } - def unapply_Cons(s: Any): Option[Tuple2[a, Seq]] -} - -class Join[a] extends Gunk[a] { - type Seq = JoinSeq - - abstract class JoinSeq - case class App(xs: Seq, ys: Seq) extends JoinSeq - - def append(s1: Seq, s2: Seq): Seq = s1 // mock implementation - - def unapply_Cons(s: Any) = s match { - case App(Cons(x, xs), ys) => Some(Pair(x, append(xs, ys))) - case _ => null - } -} diff --git a/test/pending/pos/unapplySeq.scala b/test/pending/pos/unapplySeq.scala deleted file mode 100644 index aac211de5a..0000000000 --- a/test/pending/pos/unapplySeq.scala +++ /dev/null @@ -1,26 +0,0 @@ -object FooSeq { - def unapplySeq(x:Any): Option[Product2[Int,Seq[String]]] = { - if(x.isInstanceOf[Bar]) { - val y = x.asInstanceOf[Bar] - Some({y.size, y.name}) - } else None - } - - def main(args:Array[String]) = { - val b = new Bar - b match { - case FooSeq(s:Int,_,n:String) => Console.println("size "+s+" name "+n) - } - b.size = 54 - b.name = List("large","L") - b match { - case FooSeq(s:Int,_,n:String) => Console.println("size "+s+" name "+n) - } - } -} - -class Bar { - var size: Int = 50 - var name: Seq[String] = List("medium","M") -} - diff --git a/test/pending/run/bug405.scala b/test/pending/run/bug405.scala deleted file mode 100644 index a1e3864496..0000000000 --- a/test/pending/run/bug405.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test extends Application { - val x = M; - object M; - assert(x eq M) -} diff --git a/test/pending/run/retclosure.scala b/test/pending/run/retclosure.scala deleted file mode 100644 index d354cb3586..0000000000 --- a/test/pending/run/retclosure.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* Test return expressions inside closures. - * - * See bug#834 */ - -object Test { - def response: String = { - def check: Option[String] = { - val closure: String=>Nothing = - p => return Some("some problem") // should return from check - - closure("whatever") - } - - check match { - case Some(problem) => "check failed: " + problem - case None => "ok" - } - } - - def main(args: Array[String]) { - Console.println(response) - } -} diff --git a/test/pending/run/unapply.scala b/test/pending/run/unapply.scala deleted file mode 100644 index d84711519f..0000000000 --- a/test/pending/run/unapply.scala +++ /dev/null @@ -1,86 +0,0 @@ -import scala.testing.SUnit._ - -object Test { - def main(args:Array[String]) = { - Foo.run - Mas.run - Lis.run - } -} - -// this class is used for representation -class Bar { - var size: Int = 50 - var name: String = "medium" -} - -// test basic unapply for 0, 1 and 2 args and with precise type test -object Fii { - def unapply(x: Any): boolean = x.isInstanceOf[Bar] -} -object Faa { - def unapply(x: Any): Option[String] = if(x.isInstanceOf[Bar]) Some(x.asInstanceOf[Bar].name) else None -} -object FaaPrecise { - def unapply(x: Bar): Option[String] = Some(x.name) -} -object FaaPreciseSome { - def unapply(x: Bar) = Some(x.name) // return type Some[String] -} -object Foo extends Assert { - def unapply(x: Any): Option[Product2[Int, String]] = x match { - case y: Bar => Some(Tuple(y.size, y.name)) - case _ => None - } - def doMatch1(b:Bar) = b match { - case Foo(s:Int, n:String) => {s,n} - } - def doMatch2(b:Bar) = b match { - case Fii() => null - } - def doMatch3(b:Bar) = b match { - case Faa(n:String) => n - } - def doMatch4(b:Bar) = (b:Any) match { - case FaaPrecise(n:String) => n - } - def doMatch5(b:Bar) = (b:Any) match { - case FaaPreciseSome(n:String) => n - } - def run { - val b = new Bar - assertEquals(doMatch1(b),{50,"medium"}) - assertEquals(doMatch2(b),null) - assertEquals(doMatch3(b),"medium") - assertEquals(doMatch4(b),"medium") - assertEquals(doMatch5(b),"medium") - } -} - -// same, but now object is not top-level -object Mas extends Assert { - object Gaz { - def unapply(x: Any): Option[Product2[Int, String]] = x match { - case y: Baz => Some(Tuple(y.size, y.name)) - case _ => None - } - } - class Baz { - var size: Int = 60 - var name: String = "too large" - } - def run { - val b = new Baz - assertEquals(b match { - case Gaz(s:Int, n:String) => {s,n} - }, {60,"too large"}) - } -} - -object Lis extends Assert { - def run { - assertEquals((List(1,2,3): Any) match { case List(x,y,_*) => {x,y}}, {1,2}) - } -} - - -- cgit v1.2.3