summaryrefslogtreecommitdiff
path: root/test/pending/pos
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-10-02 22:43:10 +0000
committerPaul Phillips <paulp@improving.org>2010-10-02 22:43:10 +0000
commit06aa1c9eff49d5190e82a72a876d7b3bd706d6d4 (patch)
tree4c38f2559c839ba297060a48023d69550c5d107e /test/pending/pos
parent256aca612204f1316e5281af6d10a14300d58ad1 (diff)
downloadscala-06aa1c9eff49d5190e82a72a876d7b3bd706d6d4.tar.gz
scala-06aa1c9eff49d5190e82a72a876d7b3bd706d6d4.tar.bz2
scala-06aa1c9eff49d5190e82a72a876d7b3bd706d6d4.zip
Sorting through the tests in pending from oldes...
Sorting through the tests in pending from oldest to newest because I don't believe in having useless appendages. The verdict on the oldest fifteen tests is: 15/15 are fixed. Many were already in files under a different name. I moved a few and deleted the rest. Fun fact of the day: apparently there was a time when to call into java varargs with no arguments you might have to write something like: getClass().getMethod("getCount", Array[java.lang.Class[T] forSome { type T }]()) On this basis I retract any complaints I've ever had about anything. There is one question mark outlined in pos/testCoercionThis.scala, a file formerly called pos/moors.scala and therefore... review by moors.
Diffstat (limited to 'test/pending/pos')
-rw-r--r--test/pending/pos/bug0305.scala8
-rw-r--r--test/pending/pos/bug0418.scala3
-rw-r--r--test/pending/pos/bug572.scala33
-rw-r--r--test/pending/pos/bug573.scala43
-rw-r--r--test/pending/pos/bug578.scala7
-rw-r--r--test/pending/pos/bug579.scala21
-rw-r--r--test/pending/pos/bug586.scala78
-rw-r--r--test/pending/pos/moors.scala12
-rw-r--r--test/pending/pos/unappgadteval.scala78
9 files changed, 60 insertions, 223 deletions
diff --git a/test/pending/pos/bug0305.scala b/test/pending/pos/bug0305.scala
deleted file mode 100644
index 433f0e72c3..0000000000
--- a/test/pending/pos/bug0305.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-object Test extends Application {
-
- def foo(is:int*) = 1;
- def foo(i:int) = 2;
-
- Console.println( foo( List(3):_* ) )
-
-}
diff --git a/test/pending/pos/bug0418.scala b/test/pending/pos/bug0418.scala
deleted file mode 100644
index 67007010d4..0000000000
--- a/test/pending/pos/bug0418.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test {
- null match { case Foo12340771.Bar(x) => x }
-}
diff --git a/test/pending/pos/bug572.scala b/test/pending/pos/bug572.scala
deleted file mode 100644
index 3a69cde4a6..0000000000
--- a/test/pending/pos/bug572.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-package lampion.collections;
-
-object DirX {
- abstract class Dir {
- def reverse : Dir;
- }
- object BEFORE extends Dir {
- def reverse = AFTER;
- }
- object AFTER extends Dir {
- def reverse = BEFORE;
- }
-}
-import DirX._;
-abstract class Linked {
- type Node <: Node0;
-
- abstract class Node0 {
- var next : Node = _;
- var prev : Node = _;
-
- def get(dir : Dir) = if (dir == BEFORE) prev; else next;
- private def set(dir : Dir, node : Node) =
- if (dir == BEFORE) prev = node; else next = node;
-
- def link(dir : Dir, node : Node) = {
- assert(get(dir) == null);
- assert(node.get(dir.reverse) == null);
- set(dir, node);
- node.set(dir.reverse(), node);
- }
- }
-}
diff --git a/test/pending/pos/bug573.scala b/test/pending/pos/bug573.scala
deleted file mode 100644
index b1b4f75098..0000000000
--- a/test/pending/pos/bug573.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-package lampion.collections;
-
-object DirX {
- abstract class Dir {
- def reverse : Dir;
- }
- object BEFORE extends Dir {
- def reverse = AFTER;
- }
- object AFTER extends Dir {
- def reverse = BEFORE;
- }
-}
-
-import DirX._;
-
-abstract class Linked {
- type Node <: Node0;
-
- abstract class Node0 {
- var next : Node = _;
- var prev : Node = _;
-
- def self : Node;
-
- def get(dir : Dir) = if (dir == BEFORE) prev; else next;
- private def set(dir : Dir, node : Node) =
- if (dir == BEFORE) prev = node; else next = node;
-
- def link(dir : Dir, node : Node) = {
- assert(get(dir) == null);
- assert(node.get(dir.reverse) == null);
- set(dir, node);
- node.set(dir.reverse, self);
- }
-
-
- def end(dir : Dir) : Node = {
- if (get(dir) == null) this;
- else get(dir).end(dir);
- }
- }
-}
diff --git a/test/pending/pos/bug578.scala b/test/pending/pos/bug578.scala
deleted file mode 100644
index 4899fa7f5f..0000000000
--- a/test/pending/pos/bug578.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-object Test {
- val x = Nil
- val x2: Nil = x
- val y = None
- val y2:None = y
- Console.println("Okay")
-}
diff --git a/test/pending/pos/bug579.scala b/test/pending/pos/bug579.scala
deleted file mode 100644
index a0806919e0..0000000000
--- a/test/pending/pos/bug579.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-package my.webapp.bean.stuff;
-
-import scala.reflect.BeanProperty
-
-class MyBean {
- [BeanProperty]
- var frombulizer: String = _;
-}
-
-object Test extends Application {
-
- val x = new MyBean;
- x.frombulizer = "hello"
-
- x.setFrombulizer ("hola") // synthetic methods comes too late for typechecking this code
-
- val z:String = x.frombulizer
-
- val zz:String = x.getFrombulizer // synthetic methods comes too late for typechecking this code
-
-}
diff --git a/test/pending/pos/bug586.scala b/test/pending/pos/bug586.scala
deleted file mode 100644
index b736e6ab43..0000000000
--- a/test/pending/pos/bug586.scala
+++ /dev/null
@@ -1,78 +0,0 @@
-import scala.collection.immutable.{Map, TreeMap, ListMap, ListSet, Set}
-import scala.collection.{immutable=>imm, mutable=>mut}
-
-case class HashTreeSet[A](map: imm.Map[A, Unit])
-extends Object
-with imm.Set[A]
-{
- def this() = this(null)
-
- def size = map.size
- def +(elem: A) = new HashTreeSet(map + elem -> ())
- def -(elem: A) = new HashTreeSet(map - elem)
- def contains(elem: A) = map.isDefinedAt(elem)
- def iterator = map.iterator.map(._1)
- def empty:imm.Set[A] = new HashTreeSet[A]()
-}
-
-
-abstract class Goal2 {
- type Question
- val question: Question
-
- type Answer
- def initialAnswer: Answer
-}
-
-
-
-abstract class AbstractRespondersGoal
-extends Goal2 // TYPEFIX -- comment out the extends Goal2
-{
-}
-
-class RespondersGoal(
- val question: String,
- rcvr: String,
- signature: String,
- codebase: String)
-extends AbstractRespondersGoal
-{
- type Question = String
- type Answer = imm.Set[String]
-
- val initialAnswer = new HashTreeSet[String]()// TYPEFIX .asInstanceOf[Answer]
-}
-
-
-class SingleResponderGoal(val question: String, responder: String)
-extends AbstractRespondersGoal
-{
- type Question = String
- type Answer = Set[String]
- val initialAnswer = (new ListSet[String])//TYPEFIX .asInstanceOf[Answer]
-}
-
-class RespondersGoalSet
-//extends OneKindGoalSet
-{
- type Question = String
- type Answer = imm.Set[String]
- type MyGoal = AbstractRespondersGoal
-
- var selector: Boolean = _
- def newGoal(question: String) //TYPEFIX :MyGoal
- = {
-
- selector match {
-// case StaticMethodSelector(method: MethodRef) =>
- case true =>
- new SingleResponderGoal(null, null)
-
-// case DynamicMethodSelector(signature: MethodSignature) => {
-case false => {
- new RespondersGoal(null, null,null,null)
- }
- }
- }
-}
diff --git a/test/pending/pos/moors.scala b/test/pending/pos/moors.scala
deleted file mode 100644
index 4f7346f57f..0000000000
--- a/test/pending/pos/moors.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-object Test {
-
- implicit def foo2bar(foo :Foo) :Bar = foo.bar
-
- class Foo(val bar :Bar) {
- def testCoercion ={ val a: this.type = this; a.baz /* here, foo2bar is inferred by the compiler, as expected */}
- def testCoercionThis = baz // --> error: not found: value baz
- def testCoercionThis = (this: Foo).baz // --> error: value baz is not a member of Foo
- }
-
- class Bar { def baz = System.out.println("baz")}
-}
diff --git a/test/pending/pos/unappgadteval.scala b/test/pending/pos/unappgadteval.scala
index 0c22c71dee..fce54723a1 100644
--- a/test/pending/pos/unappgadteval.scala
+++ b/test/pending/pos/unappgadteval.scala
@@ -1,19 +1,29 @@
-//Class hierarchy
+/** Cleaned up in october 2010 by paulp.
+ * Hey, we should get this working.
+ */
+
+// Class hierarchy
trait Term[a]
+
object Var{ def unapply[a](x:Var[a]) = Some(x.name) }
class Var[a] (val name : String) extends Term[a]
+
object Num{ def unapply(x:Num) = Some(x.value) }
-class Num (val value : int) extends Term[int]
-object Lam{ def unapply[b,c](l:Lam[b,c]) = Some{l.x,l.e}}
-class Lam[b, c] (val x : Var[b], val e : Term[c]) extends Term[b => c]
-object App{ def unapply[b,c](a:App[b,c]) = Some{a.f,a.e}}
+class Num (val value : Int) extends Term[Int]
+
+object Lam{ def unapply[b,c](l: Lam[b,c]) = Some(l.x, l.e) }
+class Lam[b, c](val x : Var[b], val e : Term[c]) extends Term[b => c]
+
+object App{ def unapply[b,c](a: App[b,c]) = Some(a.f, a.e) }
class App[b, c] (val f : Term[b => c], val e : Term[b]) extends Term[c]
-object Suc{ def unapply(a:Suc) = true }
-class Suc () extends Term[int => int]
+
+object Suc { def unapply(a: Suc) = true }
+class Suc() extends Term[Int => Int]
+
// Environments :
abstract class Env {
- def apply[a](v : Var[a]): a
- def extend[a](v : Var[a], x : a) = new Env {
+ def apply[a](v: Var[a]): a
+ def extend[a](v: Var[a], x : a) = new Env {
def apply[b](w: Var[b]): b = w match {
case _ : v.type => x // v eq w, hence a = b
case _ => Env.this.apply(w)
@@ -21,15 +31,47 @@ abstract class Env {
}
object empty extends Env {
- def apply[a](x : Var[a]): a = throw new Error("not found : "+x.name)
+ def apply[a](x: Var[a]): a = throw new Error("not found : "+x.name)
}
+
object Test {
-// Evaluation :
-def eval[a](t : Term[a], env : Env): a = t match {
- case v : Var[b] => env(v) // a = b
- case n @ Num(value) => value // a = int
- case i @ Suc() => { y: int => y + 1 } // a = int=>int
- case f @ Lam[b,c](x,e) => { y: b => eval(e, env.extend(x, y))} // a = b=>c
- case a @ App(f,e) => eval(f, env)(eval(e, env)) // a = c
-}
+ val v1 = new Var[util.Random]("random")
+ val v2 = new Var[Int]("Int")
+ val v3 = new Var[List[String]]("list")
+
+ val anEnv = (empty
+ .extend(v1, new util.Random)
+ .extend(v2, 58)
+ .extend(v3, Nil)
+ )
+
+ def eval[a](t: Term[a], env : Env): a = t match {
+ // First three work
+ case v : Var[b] => env(v) // a = b
+ case n @ Num(value) => value // a = Int
+ case a @ App(f,e) => eval(f, env)(eval(e, env)) // a = c
+
+ // Next one fails like:
+ //
+ // found : (Int) => Int
+ // required: a
+ case i @ Suc() => { (y: Int) => y + 1 } // a = Int => Int
+
+ // Next one fails like:
+ //
+ // error: '=>' expected but '[' found.
+ // case f @ Lam[b,c](x, e) => { (y: b) => eval(e, env.extend(x, y)) } // a = b=>c
+ // ^
+ case f @ Lam[b,c](x, e) => { (y: b) => eval(e, env.extend(x, y)) } // a = b=>c
+ }
+
+ val f1 = () => eval(v1, anEnv)
+ val f2 = () => eval(v2, anEnv)
+ val f3 = () => eval(v3, anEnv)
+
+ def main(args: Array[String]): Unit = {
+ println(f1())
+ println(f2())
+ println(f3())
+ }
}