From 943fbb1363345fdaca55e5df95059e8ce8c1344b Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 2 Oct 2010 23:19:16 +0000 Subject: The next batch of tests put up a little more st... The next batch of tests put up a little more struggle, but only a little. See test/pending/pos/unappgadteval.scala (the changes for which were in the previous commit) for an example of a test which might be on to something. Any idea what it would take to get it working? // the key lines 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 No review. --- test/files/neg/scopes.check | 35 +++++++++++++++++++++++++++++++++++ test/files/neg/scopes.scala | 20 ++++++++++++++++++++ test/files/run/bug874.check | 2 ++ test/files/run/bug874.scala | 17 +++++++++++++++++ test/files/run/records.scala | 27 +++++++++++++++++++++++++++ 5 files changed, 101 insertions(+) create mode 100644 test/files/neg/scopes.check create mode 100644 test/files/neg/scopes.scala create mode 100644 test/files/run/bug874.check create mode 100644 test/files/run/bug874.scala create mode 100644 test/files/run/records.scala (limited to 'test/files') diff --git a/test/files/neg/scopes.check b/test/files/neg/scopes.check new file mode 100644 index 0000000000..54c5d5b5e1 --- /dev/null +++ b/test/files/neg/scopes.check @@ -0,0 +1,35 @@ +scopes.scala:1: error: x is already defined as value x +case class test0(x: Int, x: Float) + ^ +scopes.scala:1: error: type mismatch; + found : Float + required: Int +case class test0(x: Int, x: Float) + ^ +scopes.scala:5: error: t is already defined as type t + type t = Float + ^ +scopes.scala:7: error: x is already defined as value x + val x: Float = .0f; + ^ +scopes.scala:10: error: y is already defined as value y + val y: Float = .0f + ^ +scopes.scala:13: error: x is already defined as value x + def f1(x: Int, x: Float) = x + ^ +scopes.scala:14: error: y is already defined as value y + def f2(x: Int)(y: Int, y: Float) = x + y + ^ +scopes.scala:15: error: x is already defined as value x + val closure = (x: Int, x: Float) => x + ^ +scopes.scala:17: error: x is already defined as value x + case x::x => x + ^ +scopes.scala:1: error: type mismatch; + found : Float + required: Int +case class test0(x: Int, x: Float) + ^ +10 errors found diff --git a/test/files/neg/scopes.scala b/test/files/neg/scopes.scala new file mode 100644 index 0000000000..fd31ff5f72 --- /dev/null +++ b/test/files/neg/scopes.scala @@ -0,0 +1,20 @@ +case class test0(x: Int, x: Float) + +object test1 { + type t = Int + type t = Float + val x: Int = 0 + val x: Float = .0f; + { + val y: Int = 0 + val y: Float = .0f + () + } + def f1(x: Int, x: Float) = x + def f2(x: Int)(y: Int, y: Float) = x + y + val closure = (x: Int, x: Float) => x + List() match { + case x::x => x + case Nil => Nil + } +} diff --git a/test/files/run/bug874.check b/test/files/run/bug874.check new file mode 100644 index 0000000000..91de7e0a03 --- /dev/null +++ b/test/files/run/bug874.check @@ -0,0 +1,2 @@ +U created with xyz and 2 +U created with abc and 1 diff --git a/test/files/run/bug874.scala b/test/files/run/bug874.scala new file mode 100644 index 0000000000..d83014651b --- /dev/null +++ b/test/files/run/bug874.scala @@ -0,0 +1,17 @@ +object Test { + abstract class Base { + val U: { + def apply[A](x1: A)(x2: Int): Any + } + U("xyz")(2) + } + class Mix extends Base { + case class U[A](x1: A)(x2: Int) { + Console.println("U created with "+x1+" and "+x2) + } + } + def main(args : Array[String]) : Unit = { + val obvious: Base = new Mix; + obvious.U("abc")(1) + } +} diff --git a/test/files/run/records.scala b/test/files/run/records.scala new file mode 100644 index 0000000000..c1dc7b67e8 --- /dev/null +++ b/test/files/run/records.scala @@ -0,0 +1,27 @@ +trait C { + def f: Int +} + +object Test { + type T = C { + def f: Int + def g: String + } + + val x: T = new C { + def f = 1 + def g = "hello" + } + + val y = new C { + def f = 2 + def g = " world" + } + + val z: T = y + + def main(args: Array[String]): Unit = { + assert(x.f+z.f == 3) + assert(x.g+z.g == "hello world") + } +} -- cgit v1.2.3