aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-10-21 18:30:53 +0200
committerMartin Odersky <odersky@gmail.com>2015-10-21 18:50:11 +0200
commit1b81e31e4b8d6a3d3ce47d1386e65754ec5099b4 (patch)
tree1583306f299f7852e4036498540868c1bb303210 /tests
parentc4882896c041774b7a8beab1dcb5b4eeee4701f1 (diff)
downloaddotty-1b81e31e4b8d6a3d3ce47d1386e65754ec5099b4.tar.gz
dotty-1b81e31e4b8d6a3d3ce47d1386e65754ec5099b4.tar.bz2
dotty-1b81e31e4b8d6a3d3ce47d1386e65754ec5099b4.zip
More tests
Diffstat (limited to 'tests')
-rw-r--r--tests/pending/neg/i827.scala0
-rw-r--r--tests/pending/pos/contraImplicits.scala18
-rw-r--r--tests/pending/pos/depsel.scala14
-rw-r--r--tests/pending/run/ordered.scala22
-rw-r--r--tests/pos/finalvals.scala8
-rw-r--r--tests/pos/freezeBounds.scala6
-rw-r--r--tests/pos/inf.scala28
-rw-r--r--tests/pos/sets.scala11
-rw-r--r--tests/run/i806.scala10
-rw-r--r--tests/run/puzzle.check2
-rw-r--r--tests/run/puzzle.scala11
11 files changed, 130 insertions, 0 deletions
diff --git a/tests/pending/neg/i827.scala b/tests/pending/neg/i827.scala
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/pending/neg/i827.scala
diff --git a/tests/pending/pos/contraImplicits.scala b/tests/pending/pos/contraImplicits.scala
new file mode 100644
index 000000000..c4d659615
--- /dev/null
+++ b/tests/pending/pos/contraImplicits.scala
@@ -0,0 +1,18 @@
+import scala.reflect._
+// this needs to be fleshed out further
+class Contra[-T]
+
+object Test {
+ def getParam[T](c: Contra[T])(implicit ct: ClassTag[T]): Unit = {
+ println(ct)
+ ct
+ }
+ def f[T](x: Contra[T]): Contra[T] = x
+
+ def main(args: Array[String]): Unit = {
+ val x = f(new Contra[Int])
+ val y: Contra[Int] = x
+ getParam(new Contra[Int])
+ }
+}
+
diff --git a/tests/pending/pos/depsel.scala b/tests/pending/pos/depsel.scala
new file mode 100644
index 000000000..2cec4349e
--- /dev/null
+++ b/tests/pending/pos/depsel.scala
@@ -0,0 +1,14 @@
+// demonstrates selection on non-path types. Needs to be fleshed out to
+// become a real test.
+object Test {
+
+ class C {
+ type T
+ val f: T => T = ???
+ }
+
+ var x = new C
+ val y = x.f
+
+
+}
diff --git a/tests/pending/run/ordered.scala b/tests/pending/run/ordered.scala
new file mode 100644
index 000000000..ffcdc624b
--- /dev/null
+++ b/tests/pending/run/ordered.scala
@@ -0,0 +1,22 @@
+// infers wrong instance --> an implementatioin is missing
+trait Ord[-T] {
+ def less(x: T, y: T): Boolean
+}
+
+object Test {
+
+ implicit val anyIsOrd: Ord[Any] = new Ord[Any] {
+ def less(x: Any, y: Any): Boolean = ???
+ }
+
+ implicit val intIsOrd: Ord[Int] = new Ord[Int] {
+ def less(x: Int, y: Int): Boolean = x < y
+ }
+
+ def less[T: Ord](x: T, y: T): Boolean =
+ implicitly[Ord[T]].less(x, y)
+
+ def main(args: Array[String]) =
+ assert(less(1, 2))
+
+}
diff --git a/tests/pos/finalvals.scala b/tests/pos/finalvals.scala
new file mode 100644
index 000000000..03a992053
--- /dev/null
+++ b/tests/pos/finalvals.scala
@@ -0,0 +1,8 @@
+object Test {
+ final val x = 2
+ final val y = { println("x"); 2 }
+ val x1 = x
+ val y1 = y
+ object O { val x = 42 }
+ println(O.x)
+}
diff --git a/tests/pos/freezeBounds.scala b/tests/pos/freezeBounds.scala
new file mode 100644
index 000000000..6cc644d99
--- /dev/null
+++ b/tests/pos/freezeBounds.scala
@@ -0,0 +1,6 @@
+object Test {
+
+ def f[X]: (Set[X], Set[X]) = ???
+
+ val a = if (true) f else (Set[Int](), Set[String]())
+}
diff --git a/tests/pos/inf.scala b/tests/pos/inf.scala
new file mode 100644
index 000000000..71bb38f57
--- /dev/null
+++ b/tests/pos/inf.scala
@@ -0,0 +1,28 @@
+object Test {
+
+ def f[T](x: T, y: T): T = x
+ def g[T](x: T)(y: T): T = x
+
+ val x: Int = 1
+ val y: Long = x
+
+ val xs: Seq[Int] = Seq(1)
+ val ys: Traversable[Int] = xs
+
+ val r1 = f(x, y)
+ val s1: AnyVal = r1
+ val r2 = f(y, x)
+ val s2: AnyVal = r2
+ val r3 = f(xs, ys)
+ val s3: Traversable[Int] = r3
+ val r4 = f(ys, xs)
+ val s4: Traversable[Int] = r4
+ val r5 = g(x)(y)
+ val s5: AnyVal = r5
+ val r6 = g(y)(x)
+ val s6: AnyVal = r6
+ val r7 = g(xs)(ys)
+ val s7: Traversable[Int]= r7
+ val r8 = g(ys)(xs)
+ val s8: Traversable[Int] = r8
+}
diff --git a/tests/pos/sets.scala b/tests/pos/sets.scala
new file mode 100644
index 000000000..577d709f5
--- /dev/null
+++ b/tests/pos/sets.scala
@@ -0,0 +1,11 @@
+object Test {
+
+ val subPatBinders = List[Symbol]()
+
+ def extraStoredBinders: Set[Symbol] = ???
+
+ val storedBinders: Set[Symbol] =
+ (if (true) subPatBinders.toSet else Set.empty) ++ extraStoredBinders// -- ignoredSubPatBinders
+
+
+}
diff --git a/tests/run/i806.scala b/tests/run/i806.scala
new file mode 100644
index 000000000..889085022
--- /dev/null
+++ b/tests/run/i806.scala
@@ -0,0 +1,10 @@
+trait T{
+ def foo(a: List[String]): String = "1"
+ def foo(a: List[Int]): Int = 1
+ foo(List("1"))
+ foo(List(1))
+}
+// to be compiled by dotty
+object Test extends T{
+ def main(args: Array[String]): Unit = ()
+}
diff --git a/tests/run/puzzle.check b/tests/run/puzzle.check
new file mode 100644
index 000000000..fc788f211
--- /dev/null
+++ b/tests/run/puzzle.check
@@ -0,0 +1,2 @@
+53.0
+53.0
diff --git a/tests/run/puzzle.scala b/tests/run/puzzle.scala
new file mode 100644
index 000000000..2f3052cb5
--- /dev/null
+++ b/tests/run/puzzle.scala
@@ -0,0 +1,11 @@
+object Test {
+
+ def main(args: Array[String]): Unit = {
+ println(if (false) 5.0 else '5')
+ val x = if (false) 5.0 else '5'
+ println(x)
+ val z = 1L
+ val y: Float = z
+ }
+
+}