From e61e59f739d889549993afdd743cbaf71a95c45e Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sat, 23 May 2015 16:48:15 +0200 Subject: Add some run tests related to value classes --- tests/pending/run/genericValueClass.check | 2 - tests/pending/run/genericValueClass.scala | 20 ----- tests/pending/run/t5608.check | 1 - tests/pending/run/t5608.scala | 12 --- tests/pending/run/t5866.check | 2 - tests/pending/run/t5866.scala | 11 --- tests/pending/run/t6260-delambdafy.check | 4 - tests/pending/run/t6260-delambdafy.flags | 1 - tests/pending/run/t6260-delambdafy.scala | 12 --- tests/pending/run/t6260.check | 1 - tests/pending/run/t6260.scala | 12 --- tests/pending/run/t6534.scala | 14 --- tests/pending/run/t6574b.check | 1 - tests/pending/run/t6574b.scala | 7 -- tests/pending/run/t7019.scala | 10 --- tests/pending/run/value-class-extractor-2.check | 8 -- tests/pending/run/value-class-extractor-2.scala | 108 ------------------------ tests/pending/run/value-class-extractor.check | 9 -- tests/pending/run/value-class-extractor.scala | 91 -------------------- tests/pending/run/valueclasses-constr.check | 10 --- tests/pending/run/valueclasses-constr.scala | 79 ----------------- 21 files changed, 415 deletions(-) delete mode 100644 tests/pending/run/genericValueClass.check delete mode 100644 tests/pending/run/genericValueClass.scala delete mode 100644 tests/pending/run/t5608.check delete mode 100644 tests/pending/run/t5608.scala delete mode 100644 tests/pending/run/t5866.check delete mode 100644 tests/pending/run/t5866.scala delete mode 100644 tests/pending/run/t6260-delambdafy.check delete mode 100644 tests/pending/run/t6260-delambdafy.flags delete mode 100644 tests/pending/run/t6260-delambdafy.scala delete mode 100644 tests/pending/run/t6260.check delete mode 100644 tests/pending/run/t6260.scala delete mode 100644 tests/pending/run/t6534.scala delete mode 100644 tests/pending/run/t6574b.check delete mode 100644 tests/pending/run/t6574b.scala delete mode 100644 tests/pending/run/t7019.scala delete mode 100644 tests/pending/run/value-class-extractor-2.check delete mode 100644 tests/pending/run/value-class-extractor-2.scala delete mode 100644 tests/pending/run/value-class-extractor.check delete mode 100644 tests/pending/run/value-class-extractor.scala delete mode 100644 tests/pending/run/valueclasses-constr.check delete mode 100644 tests/pending/run/valueclasses-constr.scala (limited to 'tests/pending/run') diff --git a/tests/pending/run/genericValueClass.check b/tests/pending/run/genericValueClass.check deleted file mode 100644 index ec3a41a6a..000000000 --- a/tests/pending/run/genericValueClass.check +++ /dev/null @@ -1,2 +0,0 @@ -(1,abc) -(2,def) diff --git a/tests/pending/run/genericValueClass.scala b/tests/pending/run/genericValueClass.scala deleted file mode 100644 index 5873eace1..000000000 --- a/tests/pending/run/genericValueClass.scala +++ /dev/null @@ -1,20 +0,0 @@ - -import scala.language.implicitConversions - -object Test extends dotty.runtime.LegacyApp { - class ArrowAssocClass[A](val __leftOfArrow: A) extends AnyVal { - @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) - def →[B](y: B): Tuple2[A, B] = ->(y) - } - - { - @inline implicit def ArrowAssoc[A](x: A): ArrowAssocClass[A] = new ArrowAssocClass(x) - val x = 1 -> "abc" - println(x) - } - - { - val y = 2 -> "def" - println(y) - } -} diff --git a/tests/pending/run/t5608.check b/tests/pending/run/t5608.check deleted file mode 100644 index ba70d2170..000000000 --- a/tests/pending/run/t5608.check +++ /dev/null @@ -1 +0,0 @@ -A@6 diff --git a/tests/pending/run/t5608.scala b/tests/pending/run/t5608.scala deleted file mode 100644 index 43e912122..000000000 --- a/tests/pending/run/t5608.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Test { - def main(args:Array[String]): Unit = { - val ns = Array(3L, 3L, 3L) - val a1: A = new A(ns(0)) - val a2: A = new A(ns(0)) - println(a1 + a2) - } -} - -class A(val u: Long) extends AnyVal { - def +(other: A) = new A(other.u + u) -} diff --git a/tests/pending/run/t5866.check b/tests/pending/run/t5866.check deleted file mode 100644 index 9f4ec729a..000000000 --- a/tests/pending/run/t5866.check +++ /dev/null @@ -1,2 +0,0 @@ -0.0 -Foo(0.0) diff --git a/tests/pending/run/t5866.scala b/tests/pending/run/t5866.scala deleted file mode 100644 index 120773eff..000000000 --- a/tests/pending/run/t5866.scala +++ /dev/null @@ -1,11 +0,0 @@ -class Foo(val d: Double) extends AnyVal { - override def toString = s"Foo($d)" -} -object Test { - def main(args: Array[String]): Unit = { - val d: Double = null.asInstanceOf[Double] - println(d) - val f: Foo = null.asInstanceOf[Foo] - println(f) - } -} diff --git a/tests/pending/run/t6260-delambdafy.check b/tests/pending/run/t6260-delambdafy.check deleted file mode 100644 index b2a7bed98..000000000 --- a/tests/pending/run/t6260-delambdafy.check +++ /dev/null @@ -1,4 +0,0 @@ -f(C@2e) - -Test$lambda$1$$apply -apply diff --git a/tests/pending/run/t6260-delambdafy.flags b/tests/pending/run/t6260-delambdafy.flags deleted file mode 100644 index 48b438ddf..000000000 --- a/tests/pending/run/t6260-delambdafy.flags +++ /dev/null @@ -1 +0,0 @@ --Ydelambdafy:method diff --git a/tests/pending/run/t6260-delambdafy.scala b/tests/pending/run/t6260-delambdafy.scala deleted file mode 100644 index a4a3cfc8f..000000000 --- a/tests/pending/run/t6260-delambdafy.scala +++ /dev/null @@ -1,12 +0,0 @@ -class C[A](private val a: Any) extends AnyVal - -object Test { - val f = (x: C[Any]) => {println(s"f($x)"); x} - def main(args: Array[String]): Unit = { - f(new C(".")) - val methods = f.getClass.getDeclaredMethods.map(_.getName).sorted - println("") - println(methods.mkString("\n")) - } -} - diff --git a/tests/pending/run/t6260.check b/tests/pending/run/t6260.check deleted file mode 100644 index 54f98a10f..000000000 --- a/tests/pending/run/t6260.check +++ /dev/null @@ -1 +0,0 @@ -Box(abcabc) diff --git a/tests/pending/run/t6260.scala b/tests/pending/run/t6260.scala deleted file mode 100644 index 3ad4926c8..000000000 --- a/tests/pending/run/t6260.scala +++ /dev/null @@ -1,12 +0,0 @@ -class Box[X <: CharSequence](val x: X) extends AnyVal { - def map[Y <: CharSequence](f: X => Y): Box[Y] = - ((bx: Box[X]) => new Box(f(bx.x)))(this) - override def toString = s"Box($x)" -} - -object Test { - def main(args: Array[String]): Unit = { - val g = (x: String) => x + x - println(new Box("abc") map g) - } -} diff --git a/tests/pending/run/t6534.scala b/tests/pending/run/t6534.scala deleted file mode 100644 index 33df97e41..000000000 --- a/tests/pending/run/t6534.scala +++ /dev/null @@ -1,14 +0,0 @@ -trait Foo extends Any { override def equals(x: Any) = false } -trait Ding extends Any { override def hashCode = -1 } - -class Bippy1(val x: Int) extends AnyVal with Foo { } // warn -class Bippy2(val x: Int) extends AnyVal with Ding { } // warn - -object Test { - def main(args: Array[String]): Unit = { - val b1 = new Bippy1(71) - val b2 = new Bippy2(71) - assert(b1 == b1 && b1.## == b1.x.##, ((b1, b1.##))) - assert(b2 == b2 && b2.## == b2.x.##, ((b2, b2.##))) - } -} diff --git a/tests/pending/run/t6574b.check b/tests/pending/run/t6574b.check deleted file mode 100644 index e10fa4f81..000000000 --- a/tests/pending/run/t6574b.check +++ /dev/null @@ -1 +0,0 @@ -List(5, 4, 3, 2, 1) diff --git a/tests/pending/run/t6574b.scala b/tests/pending/run/t6574b.scala deleted file mode 100644 index 56f952074..000000000 --- a/tests/pending/run/t6574b.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test extends dotty.runtime.LegacyApp { - implicit class AnyOps(val i: Int) extends AnyVal { - private def parentsOf(x: Int): List[Int] = if (x == 0) Nil else x :: parentsOf(x - 1) - def parents: List[Int] = parentsOf(i) - } - println((5).parents) -} diff --git a/tests/pending/run/t7019.scala b/tests/pending/run/t7019.scala deleted file mode 100644 index 5dcc09d2b..000000000 --- a/tests/pending/run/t7019.scala +++ /dev/null @@ -1,10 +0,0 @@ -final class Foo(val i: Int) extends AnyVal { - def foo() = go(i) - private[this] def go(i: Int) = i * 2 -} - -object Test { - def main(args: Array[String]): Unit = { - assert(new Foo(1).foo() == 2) - } -} diff --git a/tests/pending/run/value-class-extractor-2.check b/tests/pending/run/value-class-extractor-2.check deleted file mode 100644 index 5903b996b..000000000 --- a/tests/pending/run/value-class-extractor-2.check +++ /dev/null @@ -1,8 +0,0 @@ -String -List -Int -Something else -String -List -Int -Something else diff --git a/tests/pending/run/value-class-extractor-2.scala b/tests/pending/run/value-class-extractor-2.scala deleted file mode 100644 index d776c35ed..000000000 --- a/tests/pending/run/value-class-extractor-2.scala +++ /dev/null @@ -1,108 +0,0 @@ -final class Opt[+A >: Null](val value: A) extends AnyVal { - def get: A = value - def isEmpty = value == null -} -object Opt { - final val None = new Opt[Null](null) - def apply[A >: Null](value: A): Opt[A] = if (value == null) None else new Opt[A](value) -} - -object ValueOpt { - // public java.lang.String unapply(java.lang.Object); - // 0: aload_1 - // 1: instanceof #16 // class java/lang/String - // 4: ifeq 21 - // 7: getstatic #21 // Field Opt$.MODULE$:LOpt$; - // 10: astore_2 - // 11: ldc #23 // String String - // 13: checkcast #16 // class java/lang/String - // 16: astore 5 - // 18: goto 71 - // 21: aload_1 - // 22: instanceof #25 // class scala/collection/immutable/List - // 25: ifeq 42 - // 28: getstatic #21 // Field Opt$.MODULE$:LOpt$; - // 31: astore_3 - // 32: ldc #27 // String List - // 34: checkcast #16 // class java/lang/String - // 37: astore 5 - // 39: goto 71 - // 42: aload_1 - // 43: instanceof #29 // class java/lang/Integer - // 46: ifeq 64 - // 49: getstatic #21 // Field Opt$.MODULE$:LOpt$; - // 52: astore 4 - // 54: ldc #31 // String Int - // 56: checkcast #16 // class java/lang/String - // 59: astore 5 - // 61: goto 71 - // 64: getstatic #21 // Field Opt$.MODULE$:LOpt$; - // 67: pop - // 68: aconst_null - // 69: astore 5 - // 71: aload 5 - // 73: areturn - def unapply(x: Any): Opt[String] = x match { - case _: String => Opt("String") - case _: List[_] => Opt("List") - case _: Int => Opt("Int") - case _ => Opt.None - } -} -object RegularOpt { - // public scala.Option unapply(java.lang.Object); - // 0: aload_1 - // 1: instanceof #16 // class java/lang/String - // 4: ifeq 20 - // 7: new #18 // class scala/Some - // 10: dup - // 11: ldc #20 // String String - // 13: invokespecial #23 // Method scala/Some."":(Ljava/lang/Object;)V - // 16: astore_2 - // 17: goto 64 - // 20: aload_1 - // 21: instanceof #25 // class scala/collection/immutable/List - // 24: ifeq 40 - // 27: new #18 // class scala/Some - // 30: dup - // 31: ldc #27 // String List - // 33: invokespecial #23 // Method scala/Some."":(Ljava/lang/Object;)V - // 36: astore_2 - // 37: goto 64 - // 40: aload_1 - // 41: instanceof #29 // class java/lang/Integer - // 44: ifeq 60 - // 47: new #18 // class scala/Some - // 50: dup - // 51: ldc #31 // String Int - // 53: invokespecial #23 // Method scala/Some."":(Ljava/lang/Object;)V - // 56: astore_2 - // 57: goto 64 - // 60: getstatic #36 // Field scala/None$.MODULE$:Lscala/None$; - // 63: astore_2 - // 64: aload_2 - // 65: areturn - def unapply(x: Any): Option[String] = x match { - case _: String => Some("String") - case _: List[_] => Some("List") - case _: Int => Some("Int") - case _ => None - } -} - -object Test { - def f(x: Any) = x match { - case ValueOpt(s) => s - case _ => "Something else" - } - def g(x: Any) = x match { - case RegularOpt(s) => s - case _ => "Something else" - } - val xs = List("abc", Nil, 5, Test) - - def main(args: Array[String]): Unit = { - xs map f foreach println - xs map g foreach println - } -} diff --git a/tests/pending/run/value-class-extractor.check b/tests/pending/run/value-class-extractor.check deleted file mode 100644 index e16447118..000000000 --- a/tests/pending/run/value-class-extractor.check +++ /dev/null @@ -1,9 +0,0 @@ -'a' -'b' -'c' -NoChar -Some(a) -Some(b) -Some(c) -None -9 diff --git a/tests/pending/run/value-class-extractor.scala b/tests/pending/run/value-class-extractor.scala deleted file mode 100644 index 3eaffa0c2..000000000 --- a/tests/pending/run/value-class-extractor.scala +++ /dev/null @@ -1,91 +0,0 @@ -final class NonNullChar(val get: Char) extends AnyVal { - def isEmpty = get == 0.toChar - override def toString = if (isEmpty) "NoChar" else s"'$get'" -} -object NonNullChar { - @inline final val None = new NonNullChar(0.toChar) -} - -final class SomeProduct extends Product3[String, Int, List[String]] { - def canEqual(x: Any) = x.isInstanceOf[SomeProduct] - def _1 = "abc" - def _2 = 5 - def _3 = List("bippy") - def isEmpty = false - def get = this -} -object SomeProduct { - def unapply(x: SomeProduct) = x -} - -object Test { - def prod(x: SomeProduct): Int = x match { - case SomeProduct(x, y, z) => x.length + y + z.length - case _ => -1 - } - - def f(x: Char): NonNullChar = x match { - case 'a' => new NonNullChar('a') - case 'b' => new NonNullChar('b') - case 'c' => new NonNullChar('c') - case _ => NonNullChar.None - } - // public char f(char); - // 0: iload_1 - // 1: tableswitch { // 97 to 99 - // 97: 47 - // 98: 42 - // 99: 37 - // default: 28 - // } - // 28: getstatic #19 // Field NonNullChar$.MODULE$:LNonNullChar$; - // 31: invokevirtual #23 // Method NonNullChar$.None:()C - // 34: goto 49 - // 37: bipush 99 - // 39: goto 49 - // 42: bipush 98 - // 44: goto 49 - // 47: bipush 97 - // 49: ireturn - def g(x: Char): Option[Char] = x match { - case 'a' => Some('a') - case 'b' => Some('b') - case 'c' => Some('c') - case _ => None - } - // public scala.Option g(char); - // 0: iload_1 - // 1: tableswitch { // 97 to 99 - // 97: 64 - // 98: 49 - // 99: 34 - // default: 28 - // } - // 28: getstatic #33 // Field scala/None$.MODULE$:Lscala/None$; - // 31: goto 76 - // 34: new #35 // class scala/Some - // 37: dup - // 38: bipush 99 - // 40: invokestatic #41 // Method scala/runtime/BoxesRunTime.boxToCharacter:(C)Ljava/lang/Character; - // 43: invokespecial #44 // Method scala/Some."":(Ljava/lang/Object;)V - // 46: goto 76 - // 49: new #35 // class scala/Some - // 52: dup - // 53: bipush 98 - // 55: invokestatic #41 // Method scala/runtime/BoxesRunTime.boxToCharacter:(C)Ljava/lang/Character; - // 58: invokespecial #44 // Method scala/Some."":(Ljava/lang/Object;)V - // 61: goto 76 - // 64: new #35 // class scala/Some - // 67: dup - // 68: bipush 97 - // 70: invokestatic #41 // Method scala/runtime/BoxesRunTime.boxToCharacter:(C)Ljava/lang/Character; - // 73: invokespecial #44 // Method scala/Some."":(Ljava/lang/Object;)V - // 76: areturn - def main(args: Array[String]): Unit = { - "abcd" foreach (ch => println(f(ch))) - "abcd" foreach (ch => println(g(ch))) - println(prod(new SomeProduct)) - } -} - - diff --git a/tests/pending/run/valueclasses-constr.check b/tests/pending/run/valueclasses-constr.check deleted file mode 100644 index 785e6fa25..000000000 --- a/tests/pending/run/valueclasses-constr.check +++ /dev/null @@ -1,10 +0,0 @@ -16 -00:16:40 -16 -00:16:40 -16 -00:16:40 -16 -00:16:40 -16 -00:16:40 diff --git a/tests/pending/run/valueclasses-constr.scala b/tests/pending/run/valueclasses-constr.scala deleted file mode 100644 index 73ac29435..000000000 --- a/tests/pending/run/valueclasses-constr.scala +++ /dev/null @@ -1,79 +0,0 @@ -package test1 { - object TOD { - final val SecondsPerDay = 86400 - - def apply(seconds: Int) = { - val n = seconds % SecondsPerDay - new TOD(if (n >= 0) n else n + SecondsPerDay) - } - } - - final class TOD (val secondsOfDay: Int) extends AnyVal { - def hours = secondsOfDay / 3600 - def minutes = (secondsOfDay / 60) % 60 - def seconds = secondsOfDay % 60 - - override def toString = "%02d:%02d:%02d".format(hours, minutes, seconds) - } -} -package test2 { - object TOD { - final val SecondsPerDay = 86400 - - def apply(seconds: Int) = { - val n = seconds % SecondsPerDay - new TOD(if (n >= 0) n else n + SecondsPerDay) - } - } - - final class TOD private[test2] (val secondsOfDay: Int) extends AnyVal { - def hours = secondsOfDay / 3600 - def minutes = (secondsOfDay / 60) % 60 - def seconds = secondsOfDay % 60 - - override def toString = "%02d:%02d:%02d".format(hours, minutes, seconds) - } - - object Client { - def newTOD(x: Int) = new TOD(x) - } -} - -package test3 { - object TOD { - final val SecondsPerDay = 86400 - - def apply(seconds: Int) = { - val n = seconds % SecondsPerDay - new TOD(if (n >= 0) n else n + SecondsPerDay) - } - } - - final class TOD private (val secondsOfDay: Int) extends AnyVal { - def hours = secondsOfDay / 3600 - def minutes = (secondsOfDay / 60) % 60 - def seconds = secondsOfDay % 60 - - override def toString = "%02d:%02d:%02d".format(hours, minutes, seconds) - } -} - -object Test extends dotty.runtime.LegacyApp { - - val y1: test1.TOD = new test1.TOD(1000) - val y2: test2.TOD = test2.Client.newTOD(1000) - val x1: test1.TOD = test1.TOD(1000) - val x2: test2.TOD = test2.TOD(1000) - val x3: test3.TOD = test3.TOD(1000) - println(y1.minutes) - println(y1) - println(y2.minutes) - println(y2) - println(x1.minutes) - println(x1) - println(x2.minutes) - println(x2) - println(x3.minutes) - println(x3) -} - -- cgit v1.2.3