diff options
author | Hubert Plociniczak <hubert.plociniczak@epfl.ch> | 2011-11-02 14:34:35 +0000 |
---|---|---|
committer | Hubert Plociniczak <hubert.plociniczak@epfl.ch> | 2011-11-02 14:34:35 +0000 |
commit | b6778be91900b8161e705dc2598ef7af86842b0b (patch) | |
tree | d15e8ec18a37eec212f50f1ace27714d7e7d4d34 /test/pending/pos/unappgadteval.scala | |
parent | ac6c76f26d884a94d0c9ff54f055d3f9ab750bac (diff) | |
download | scala-b6778be91900b8161e705dc2598ef7af86842b0b.tar.gz scala-b6778be91900b8161e705dc2598ef7af86842b0b.tar.bz2 scala-b6778be91900b8161e705dc2598ef7af86842b0b.zip |
Begone t1737...
Diffstat (limited to 'test/pending/pos/unappgadteval.scala')
-rw-r--r-- | test/pending/pos/unappgadteval.scala | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/test/pending/pos/unappgadteval.scala b/test/pending/pos/unappgadteval.scala index fce54723a1..89f6cabc43 100644 --- a/test/pending/pos/unappgadteval.scala +++ b/test/pending/pos/unappgadteval.scala @@ -21,30 +21,30 @@ object Suc { def unapply(a: Suc) = true } class Suc() extends Term[Int => Int] // Environments : -abstract class Env { +abstract class 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 { + def apply[b](w: Var[b]): b = w match { case _ : v.type => x // v eq w, hence a = b case _ => Env.this.apply(w) }} } -object empty extends Env { - def apply[a](x: Var[a]): a = throw new Error("not found : "+x.name) +object empty extends Env { + def apply[a](x: Var[a]): a = throw new Error("not found : "+x.name) } object Test { 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 @@ -54,9 +54,9 @@ object Test { // Next one fails like: // // found : (Int) => Int - // required: a + // required: a case i @ Suc() => { (y: Int) => y + 1 } // a = Int => Int - + // Next one fails like: // // error: '=>' expected but '[' found. @@ -64,11 +64,11 @@ object Test { // ^ 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()) |