diff options
author | Martin Odersky <odersky@gmail.com> | 2016-08-23 15:19:10 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-09-14 13:22:20 +0200 |
commit | 51201d23cf0b1e06ab7ab8ea8213c48d5ca12f13 (patch) | |
tree | 568114214b013a6ebe1efc0993e63465689c46b6 /tests/pending | |
parent | d63dd11ed31f5b500fd08d630bbaec144dbee370 (diff) | |
download | dotty-51201d23cf0b1e06ab7ab8ea8213c48d5ca12f13.tar.gz dotty-51201d23cf0b1e06ab7ab8ea8213c48d5ca12f13.tar.bz2 dotty-51201d23cf0b1e06ab7ab8ea8213c48d5ca12f13.zip |
Add some run tests
Diffstat (limited to 'tests/pending')
-rw-r--r-- | tests/pending/run/t2337.check | 4 | ||||
-rw-r--r-- | tests/pending/run/t2337.scala | 21 | ||||
-rw-r--r-- | tests/pending/run/t298.scala | 17 | ||||
-rw-r--r-- | tests/pending/run/t3026.check | 2 | ||||
-rwxr-xr-x | tests/pending/run/t3026.scala | 8 | ||||
-rw-r--r-- | tests/pending/run/t3050.scala | 9 | ||||
-rw-r--r-- | tests/pending/run/t3150.scala | 36 | ||||
-rw-r--r-- | tests/pending/run/t3353.check | 1 | ||||
-rw-r--r-- | tests/pending/run/t3353.scala | 10 | ||||
-rw-r--r-- | tests/pending/run/unapply.check | 3 | ||||
-rw-r--r-- | tests/pending/run/unapply.scala | 122 |
11 files changed, 26 insertions, 207 deletions
diff --git a/tests/pending/run/t2337.check b/tests/pending/run/t2337.check deleted file mode 100644 index 18f1f66fc..000000000 --- a/tests/pending/run/t2337.check +++ /dev/null @@ -1,4 +0,0 @@ -(Both Int,-1,-1) -(Both Float,1,1) -(Float then Int,0,0) -(Int then Float,0,0) diff --git a/tests/pending/run/t2337.scala b/tests/pending/run/t2337.scala deleted file mode 100644 index edb574cba..000000000 --- a/tests/pending/run/t2337.scala +++ /dev/null @@ -1,21 +0,0 @@ - -object Test { - - def compare(first: Any, second: Any): Any = { - (first, second) match { - case (k: Int, o: Int) => k compare o - //why the next case matches (Float, Int) but does not match (Int, Float) ??? - case (k: Number, o: Number) => k.doubleValue() compare o.doubleValue() - case _ => "BOGON" - // throw new Exception("Unsupported compare " + first + "; " + second) - } - } - - def main(args: Array[String]): Unit = { - println("Both Int", -1, compare(0, 1)) - println("Both Float", 1, compare(1.0, 0.0)) - println("Float then Int", 0, compare(10.0, 10)) - println("Int then Float", 0, compare(10, 10.0)) //this fails with an exception - } -} - diff --git a/tests/pending/run/t298.scala b/tests/pending/run/t298.scala deleted file mode 100644 index 5728bb6c9..000000000 --- a/tests/pending/run/t298.scala +++ /dev/null @@ -1,17 +0,0 @@ -object Test extends dotty.runtime.LegacyApp { - implicit def anyList[T]: List[T] = Nil - - implicit def intList: List[Int] = 42::24::Nil - - def foo[T](implicit x: T) = x - - val s = foo[List[Int]] - - println(s) // correct - prints "List(42, 24)" - - implicit def tupleList[T](implicit t: List[T]): List[(T,T)] = t.map(x => (x,x)) - - val t = foo[List[Tuple2[Int,Int]]] - - println(t) // incorrect - prints "List()" -} diff --git a/tests/pending/run/t3026.check b/tests/pending/run/t3026.check deleted file mode 100644 index 8c29b615f..000000000 --- a/tests/pending/run/t3026.check +++ /dev/null @@ -1,2 +0,0 @@ -RED -YELLOW diff --git a/tests/pending/run/t3026.scala b/tests/pending/run/t3026.scala deleted file mode 100755 index 22dde9cc0..000000000 --- a/tests/pending/run/t3026.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - abstract class Colour - case object RED extends Colour - case object YELLOW extends Colour - val items = Array(RED, YELLOW) - - def main(args: Array[String]): Unit = items foreach println -} diff --git a/tests/pending/run/t3050.scala b/tests/pending/run/t3050.scala deleted file mode 100644 index 160f8b664..000000000 --- a/tests/pending/run/t3050.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - val x = - try { ("": Any) match { case List(_*) => true } } - catch { case _: Throwable => false } - - assert(!x) - } -} diff --git a/tests/pending/run/t3150.scala b/tests/pending/run/t3150.scala index 034703b5f..dc95af373 100644 --- a/tests/pending/run/t3150.scala +++ b/tests/pending/run/t3150.scala @@ -1,10 +1,26 @@ -object Test { - case object Bob { override def equals(other: Any) = true } - def f(x: Any) = x match { case Bob => Bob } - - def main(args: Array[String]): Unit = { - assert(f(Bob) eq Bob) - assert(f(0) eq Bob) - assert(f(Nil) eq Bob) - } -} + object Test { + case object Bob { override def equals(other: Any) = true } + + class Bob2 { + override def equals(other: Any) = true + } + val Bob2 = new Bob2 + + def f0(x: Any) = x match { case Bob2 => Bob2 } // class cast exception at runtime, dotc only + def f1(x: Any) = x match { case Bob => Bob } // class cast exception at runtime, dotc only + def f2(x: Any): Bob.type = x match { case x @ Bob => x } // class cast exception at runtime, dotc and javac. + + def main(args: Array[String]): Unit = { + assert(f0(Bob2) eq Bob2) + assert(f0(0) eq Bob2) // only dotty fails here + assert(f0(Nil) eq Bob2) + + assert(f1(Bob) eq Bob) + assert(f1(0) eq Bob) // only dotty fails here + assert(f1(Nil) eq Bob) + + assert(f2(Bob) eq Bob) + assert(f2(0) eq Bob) // both dotty and scalac fail here + assert(f2(Nil) eq Bob) + } + } diff --git a/tests/pending/run/t3353.check b/tests/pending/run/t3353.check deleted file mode 100644 index 8b4ae1fe6..000000000 --- a/tests/pending/run/t3353.check +++ /dev/null @@ -1 +0,0 @@ -Got: foo and None diff --git a/tests/pending/run/t3353.scala b/tests/pending/run/t3353.scala deleted file mode 100644 index 472723b3c..000000000 --- a/tests/pending/run/t3353.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test extends dotty.runtime.LegacyApp { - - "foo" match { - case Matcher(result) => println(result) - } - - object Matcher{ - def unapply(s: String)(implicit secondParam: Option[String] = None) = Some("Got: " + s + " and " + secondParam) - } -} diff --git a/tests/pending/run/unapply.check b/tests/pending/run/unapply.check deleted file mode 100644 index 847e3b381..000000000 --- a/tests/pending/run/unapply.check +++ /dev/null @@ -1,3 +0,0 @@ -unapply.scala:57: warning: comparing values of types Null and Null using `==' will always yield true - assert(doMatch2(b) == null) - ^ diff --git a/tests/pending/run/unapply.scala b/tests/pending/run/unapply.scala deleted file mode 100644 index 43f02b9f3..000000000 --- a/tests/pending/run/unapply.scala +++ /dev/null @@ -1,122 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - Foo.run() - Mas.run() - LisSeqArr.run() - StreamFoo.run() - Test1256.run() - } -} - -// this class is used for representation -class Bar { - var size: Int = 50 - var name: String = "medium" -} - -// test basic unapply for 0, 1 and 2 args and with precise type test -object Fii { - def unapply(x: Any): Boolean = x.isInstanceOf[Bar] -} -object Faa { - def unapply(x: Any): Option[String] = if(x.isInstanceOf[Bar]) Some(x.asInstanceOf[Bar].name) else None -} -object FaaPrecise { - def unapply(x: Bar): Option[String] = Some(x.name) -} -object FaaPreciseSome { - def unapply(x: Bar) = Some(x.name) // return type Some[String] -} -object VarFoo { - def unapply(a : Int)(implicit b : Int) : Option[Int] = Some(a + b) -} - -object Foo { - def unapply(x: Any): Option[Product2[Int, String]] = x match { - case y: Bar => Some(y.size, y.name) - case _ => None - } - def doMatch1(b:Bar) = b match { - case Foo(s:Int, n:String) => (s,n) - } - def doMatch2(b:Bar) = b match { - case Fii() => null - } - def doMatch3(b:Bar) = b match { - case Faa(n:String) => n - } - def doMatch4(b:Bar) = (b:Any) match { - case FaaPrecise(n:String) => n - } - def doMatch5(b:Bar) = (b:Any) match { - case FaaPreciseSome(n:String) => n - } - def run(): Unit = { - val b = new Bar - assert(doMatch1(b) == (50,"medium")) - assert(doMatch2(b) == null) - assert(doMatch3(b) == "medium") - assert(doMatch4(b) == "medium") - assert(doMatch5(b) == "medium") - implicit val bc: Int = 3 - assert(7 == (4 match { - case VarFoo(x) => x - })) - } -} - -// same, but now object is not top-level -object Mas { - object Gaz { - def unapply(x: Any): Option[Product2[Int, String]] = x match { - case y: Baz => Some(y.size, y.name) - case _ => None - } - } - class Baz { - var size: Int = 60 - var name: String = "too large" - } - def run(): Unit = { - val b = new Baz - assert((60,"too large") == (b match { - case Gaz(s:Int, n:String) => (s,n) - })) - } -} - -object LisSeqArr { - def run(): Unit = { - assert((1,2) == ((List(1,2,3): Any) match { case List(x,y,_*) => (x,y)})) - assert((1,2) == ((List(1,2,3): Any) match { case Seq(x,y,_*) => (x,y)})) - } -} - -object StreamFoo { - def sum(stream: Stream[Int]): Int = - stream match { - case Stream.Empty => 0 - case Stream.cons(hd, tl) => hd + sum(tl) - } - def run(): Unit = { - val str: Stream[Int] = List(1,2,3).toStream - assert(6 == sum(str)) - } -} - -object Test1256 { - class Sync { - def unapply(scrut: Any): Boolean = false - } - - class Buffer { - val Get = new Sync - val jp: PartialFunction[Any, Any] = { - case Get() => - } - } - - def run(): Unit = { - assert(!(new Buffer).jp.isDefinedAt(42)) - } -} |