diff options
author | Martin Odersky <odersky@gmail.com> | 2016-10-01 21:51:34 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-10-11 19:21:02 +0200 |
commit | 25c0398b6f07df2449652e66cef8b6a6d3d4c7ce (patch) | |
tree | 75124ba8ba9d7663b7c6f2b739c55f828406386e | |
parent | 3d74bfa72bdc794cfb11b6afe15c77a5357617d1 (diff) | |
download | dotty-25c0398b6f07df2449652e66cef8b6a6d3d4c7ce.tar.gz dotty-25c0398b6f07df2449652e66cef8b6a6d3d4c7ce.tar.bz2 dotty-25c0398b6f07df2449652e66cef8b6a6d3d4c7ce.zip |
Adapt tests
-rw-r--r-- | tests/neg/OrType.scala (renamed from tests/run/OrType.scala) | 2 | ||||
-rw-r--r-- | tests/neg/unions.scala (renamed from tests/pickling/unions.scala) | 9 | ||||
-rw-r--r-- | tests/pos/i1045.scala | 17 | ||||
-rw-r--r-- | tests/pos/union.scala | 11 | ||||
-rw-r--r-- | tests/pos/unions.scala | 32 | ||||
-rw-r--r-- | tests/run/OrderingTest.scala | 3 | ||||
-rw-r--r-- | tests/run/flat-flat-flat.scala | 4 |
7 files changed, 39 insertions, 39 deletions
diff --git a/tests/run/OrType.scala b/tests/neg/OrType.scala index 9ab805def..a9860db93 100644 --- a/tests/run/OrType.scala +++ b/tests/neg/OrType.scala @@ -2,7 +2,7 @@ class B(val x: Int) class C(val x: Double) object Test{ - def bar(x: B | C): Int | Double = x.x + def bar(x: B | C): Int | Double = x.x // error def main(args: Array[String]): Unit = { val b = new B(1) val c = new C(1) diff --git a/tests/pickling/unions.scala b/tests/neg/unions.scala index 22e6391e3..099a628c9 100644 --- a/tests/pickling/unions.scala +++ b/tests/neg/unions.scala @@ -16,11 +16,10 @@ object unions { val x: A | B = if (true) new A else new B def y: B | A = if (true) new A else new B - println(x.f) - println(x.g(2)) - println(y.f) - println(y.g(1.0)) - println(y.g(1.0f)) + println(x.f) // error + println(x.g(2)) // error + println(y.f) // error + println(y.g(1.0)) // error class C { private def foo = 0 diff --git a/tests/pos/i1045.scala b/tests/pos/i1045.scala index f5985af92..f0cf1df90 100644 --- a/tests/pos/i1045.scala +++ b/tests/pos/i1045.scala @@ -1,7 +1,24 @@ import scala.collection._ + +object EmptyHashMap extends mutable.HashMap[Nothing, Nothing] object T { val newSymbolMap: mutable.HashMap[String, mutable.HashMap[Int, Double]] = mutable.HashMap.empty val map = newSymbolMap.getOrElse("a", mutable.HashMap.empty) map.put(1, 0.0) newSymbolMap.put("a", map) + + /** A map storing free variables of functions and classes */ +// type SymSet = Set[Symbol] +// private val free = new collection.mutable.LinkedHashMap[Symbol, SymSet] +// def freeVars(sym: Symbol): List[Symbol] = free.getOrElse(sym, Nil).toList + + class Tree[X >: Null] { def tpe: X = null } + class Ident[X >: Null] extends Tree[X] + class Apply[X >: Null] extends Tree[X] + + val x: Ident[Symbol] | Apply[Symbol] = ??? + val y = x.tpe + val z: Symbol = y + + } diff --git a/tests/pos/union.scala b/tests/pos/union.scala new file mode 100644 index 000000000..8b20a8458 --- /dev/null +++ b/tests/pos/union.scala @@ -0,0 +1,11 @@ +object Test { + + class A + class B extends A + class C extends A + class D extends A + + val b = true + val x = if (b) new B else new C + val y: B | C = x +} diff --git a/tests/pos/unions.scala b/tests/pos/unions.scala deleted file mode 100644 index e57a96fb9..000000000 --- a/tests/pos/unions.scala +++ /dev/null @@ -1,32 +0,0 @@ -object unions { - - class A { - def f: String = "abc" - - def g(x: Int): Int = x - def g(x: Double): Double = x - } - - class B { - def f: String = "bcd" - - def g(x: Int) = -x - def g(x: Double): Double = -x - } - - val x: A | B = if (true) new A else new B - def y: B | A = if (true) new A else new B - println(x.f) - println(x.g(2)) - println(y.f) - println(y.g(1.0)) - - class C { - private def foo = 0 - class D extends C { - private def foo = 1 - def test(cd: C | D, dc: D | C) = (cd.foo, dc.foo) - } - } - -} diff --git a/tests/run/OrderingTest.scala b/tests/run/OrderingTest.scala index ad5acfa0c..561a3daeb 100644 --- a/tests/run/OrderingTest.scala +++ b/tests/run/OrderingTest.scala @@ -23,7 +23,8 @@ object Test extends dotty.runtime.LegacyApp { testAll(false, true) testAll(1, 2); testAll(1.0, 2.0); - testAll(None, Some(1)); + // testAll(Some(1), Some(2)) // does not work in nsc or dotty + // testAll(None, Some(1)); // does not work in dotty with or-types testAll[Iterable[Int]](List(1), List(1, 2)); testAll[Iterable[Int]](List(1, 2), List(2)); testAll((1, "bar"), (1, "foo")) diff --git a/tests/run/flat-flat-flat.scala b/tests/run/flat-flat-flat.scala index 80868b9c5..e0fabe4e7 100644 --- a/tests/run/flat-flat-flat.scala +++ b/tests/run/flat-flat-flat.scala @@ -2,10 +2,14 @@ object Test { def f1 = List(Iterator(Some(1), None, Some(2)), Iterator(Some(3), None)) def f2 = Iterator(List(Some(1), None, Some(2)), List(Some(3), None), Nil) def f3 = List(Some(Iterator(1)), None, Some(Iterator(2, 3))) + def f4 = List(Some(Iterator(1)), Some(Iterator(2, 3))) + def f5 = Iterator(List(Some(1), Some(2)), List(Some(3)), Nil) def main(args: Array[String]): Unit = { assert(f1.flatten.flatten.toList == List(1, 2, 3)) + assert(f5.flatten.flatten.toList == List(1, 2, 3)) assert(f2.flatten.flatten.toList == List(1, 2, 3)) assert(f3.flatten.flatten.toList == List(1, 2, 3)) + assert(f4.flatten.flatten.toList == List(1, 2, 3)) } } |