summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/Meter.check21
-rw-r--r--test/files/run/Meter.scala102
-rw-r--r--test/files/run/MeterCaseClass.check21
-rw-r--r--test/files/run/MeterCaseClass.scala99
-rw-r--r--test/files/run/genericValueClass.check2
-rw-r--r--test/files/run/genericValueClass.scala17
-rw-r--r--test/files/run/primitive-sigs-2.check2
-rw-r--r--test/files/run/programmatic-main.check31
-rw-r--r--test/files/run/t4110.check4
-rw-r--r--test/files/run/t4172.check2
-rw-r--r--test/files/run/valueclasses-constr.check2
-rw-r--r--test/files/run/valueclasses-constr.scala25
12 files changed, 309 insertions, 19 deletions
diff --git a/test/files/run/Meter.check b/test/files/run/Meter.check
new file mode 100644
index 0000000000..7562f9a1bf
--- /dev/null
+++ b/test/files/run/Meter.check
@@ -0,0 +1,21 @@
+2.0
+4.0m
+false
+x.isInstanceOf[Meter]: true
+x.hashCode: 1072693248
+x == 1: false
+x == y: true
+a == b: true
+testing native arrays
+Array(1.0m, 2.0m)
+1.0m
+>>>1.0m<<< 1.0m
+>>>2.0m<<< 2.0m
+testing wrapped arrays
+FlatArray(1.0m, 2.0m)
+1.0m
+>>>1.0m<<< 1.0m
+>>>2.0m<<< 2.0m
+FlatArray(2.0m, 3.0m)
+ArrayBuffer(1.0, 2.0)
+FlatArray(0.3048ft, 0.6096ft)
diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala
new file mode 100644
index 0000000000..42a3aac5f8
--- /dev/null
+++ b/test/files/run/Meter.scala
@@ -0,0 +1,102 @@
+package a {
+ class Meter(val underlying: Double) extends AnyVal with _root_.b.Printable {
+ def + (other: Meter): Meter =
+ new Meter(this.underlying + other.underlying)
+ def / (other: Meter): Double = this.underlying / other.underlying
+ def / (factor: Double): Meter = new Meter(this.underlying / factor)
+ def < (other: Meter): Boolean = this.underlying < other.underlying
+ def toFoot: Foot = new Foot(this.underlying * 0.3048)
+ override def print = { Console.print(">>>"); super.print; proprint }
+ override def toString: String = underlying.toString+"m"
+ }
+
+ object Meter extends (Double => Meter) {
+
+ def apply(x: Double): Meter = new Meter(x)
+
+ implicit val boxings = new BoxingConversions[Meter, Double] {
+ def box(x: Double) = new Meter(x)
+ def unbox(m: Meter) = m.underlying
+ }
+ }
+
+ class Foot(val unbox: Double) extends AnyVal {
+ def + (other: Foot): Foot =
+ new Foot(this.unbox + other.unbox)
+ override def toString = unbox.toString+"ft"
+ }
+ object Foot {
+ implicit val boxings = new BoxingConversions[Foot, Double] {
+ def box(x: Double) = new Foot(x)
+ def unbox(m: Foot) = m.unbox
+ }
+ }
+
+}
+package b {
+ trait Printable extends Any {
+ def print: Unit = Console.print(this)
+ protected def proprint = Console.print("<<<")
+ }
+}
+import a._
+import _root_.b._
+object Test extends App {
+
+ {
+ val x: Meter = new Meter(1)
+ val a: Object = x.asInstanceOf[Object]
+ val y: Meter = a.asInstanceOf[Meter]
+
+ val u: Double = 1
+ val b: Object = u.asInstanceOf[Object]
+ val v: Double = b.asInstanceOf[Double]
+ }
+
+ val x = new Meter(1)
+ val y = x
+ println((x + x) / x)
+ println((x + x) / 0.5)
+ println((x < x).toString)
+ println("x.isInstanceOf[Meter]: "+x.isInstanceOf[Meter])
+
+
+ println("x.hashCode: "+x.hashCode)
+ println("x == 1: "+(x == 1))
+ println("x == y: "+(x == y))
+ assert(x.hashCode == (1.0).hashCode)
+
+ val a: Any = x
+ val b: Any = y
+ println("a == b: "+(a == b))
+
+ { println("testing native arrays")
+ val arr = Array(x, y + x)
+ println(arr.deep)
+ def foo[T <: Printable](x: Array[T]) {
+ for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) }
+ }
+ val m = arr(0)
+ println(m)
+ foo(arr)
+ }
+
+ { println("testing wrapped arrays")
+ import collection.mutable.FlatArray
+ val arr = FlatArray(x, y + x)
+ println(arr)
+ def foo(x: FlatArray[Meter]) {
+ for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) }
+ }
+ val m = arr(0)
+ println(m)
+ foo(arr)
+ val ys: Seq[Meter] = arr map (_ + new Meter(1))
+ println(ys)
+ val zs = arr map (_ / Meter(1))
+ println(zs)
+ val fs = arr map (_.toFoot)
+ println(fs)
+ }
+
+}
diff --git a/test/files/run/MeterCaseClass.check b/test/files/run/MeterCaseClass.check
new file mode 100644
index 0000000000..08370d2097
--- /dev/null
+++ b/test/files/run/MeterCaseClass.check
@@ -0,0 +1,21 @@
+2.0
+Meter(4.0)
+false
+x.isInstanceOf[Meter]: true
+x.hashCode: 1072693248
+x == 1: false
+x == y: true
+a == b: true
+testing native arrays
+Array(Meter(1.0), Meter(2.0))
+Meter(1.0)
+>>>Meter(1.0)<<< Meter(1.0)
+>>>Meter(2.0)<<< Meter(2.0)
+testing wrapped arrays
+FlatArray(Meter(1.0), Meter(2.0))
+Meter(1.0)
+>>>Meter(1.0)<<< Meter(1.0)
+>>>Meter(2.0)<<< Meter(2.0)
+FlatArray(Meter(2.0), Meter(3.0))
+ArrayBuffer(1.0, 2.0)
+FlatArray(0.3048ft, 0.6096ft)
diff --git a/test/files/run/MeterCaseClass.scala b/test/files/run/MeterCaseClass.scala
new file mode 100644
index 0000000000..4f082b5252
--- /dev/null
+++ b/test/files/run/MeterCaseClass.scala
@@ -0,0 +1,99 @@
+package a {
+ case class Meter(underlying: Double) extends AnyVal with _root_.b.Printable {
+ def + (other: Meter): Meter =
+ new Meter(this.underlying + other.underlying)
+ def / (other: Meter): Double = this.underlying / other.underlying
+ def / (factor: Double): Meter = new Meter(this.underlying / factor)
+ def < (other: Meter): Boolean = this.underlying < other.underlying
+ def toFoot: Foot = new Foot(this.underlying * 0.3048)
+ override def print = { Console.print(">>>"); super.print; proprint }
+ }
+
+ object Meter extends (Double => Meter) {
+
+ implicit val boxings = new BoxingConversions[Meter, Double] {
+ def box(x: Double) = new Meter(x)
+ def unbox(m: Meter) = m.underlying
+ }
+ }
+
+ class Foot(val unbox: Double) extends AnyVal {
+ def + (other: Foot): Foot =
+ new Foot(this.unbox + other.unbox)
+ override def toString = unbox.toString+"ft"
+ }
+ object Foot {
+ implicit val boxings = new BoxingConversions[Foot, Double] {
+ def box(x: Double) = new Foot(x)
+ def unbox(m: Foot) = m.unbox
+ }
+ }
+
+}
+package b {
+ trait Printable extends Any {
+ def print: Unit = Console.print(this)
+ protected def proprint = Console.print("<<<")
+ }
+}
+import a._
+import _root_.b._
+object Test extends App {
+
+ {
+ val x: Meter = new Meter(1)
+ val a: Object = x.asInstanceOf[Object]
+ val y: Meter = a.asInstanceOf[Meter]
+
+ val u: Double = 1
+ val b: Object = u.asInstanceOf[Object]
+ val v: Double = b.asInstanceOf[Double]
+ }
+
+ val x = new Meter(1)
+ val y = x
+ println((x + x) / x)
+ println((x + x) / 0.5)
+ println((x < x).toString)
+ println("x.isInstanceOf[Meter]: "+x.isInstanceOf[Meter])
+
+
+ println("x.hashCode: "+x.hashCode)
+ println("x == 1: "+(x == 1))
+ println("x == y: "+(x == y))
+ assert(x.hashCode == (1.0).hashCode)
+
+ val a: Any = x
+ val b: Any = y
+ println("a == b: "+(a == b))
+
+ { println("testing native arrays")
+ val arr = Array(x, y + x)
+ println(arr.deep)
+ def foo[T <: Printable](x: Array[T]) {
+ for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) }
+ }
+ val m = arr(0)
+ println(m)
+ foo(arr)
+ }
+
+ { println("testing wrapped arrays")
+ import collection.mutable.FlatArray
+ val arr = FlatArray(x, y + x)
+ println(arr)
+ def foo(x: FlatArray[Meter]) {
+ for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) }
+ }
+ val m = arr(0)
+ println(m)
+ foo(arr)
+ val ys: Seq[Meter] = arr map (_ + new Meter(1))
+ println(ys)
+ val zs = arr map (_ / Meter(1))
+ println(zs)
+ val fs = arr map (_.toFoot)
+ println(fs)
+ }
+
+}
diff --git a/test/files/run/genericValueClass.check b/test/files/run/genericValueClass.check
new file mode 100644
index 0000000000..ec3a41a6a9
--- /dev/null
+++ b/test/files/run/genericValueClass.check
@@ -0,0 +1,2 @@
+(1,abc)
+(2,def)
diff --git a/test/files/run/genericValueClass.scala b/test/files/run/genericValueClass.scala
new file mode 100644
index 0000000000..68162bb685
--- /dev/null
+++ b/test/files/run/genericValueClass.scala
@@ -0,0 +1,17 @@
+final class ArrowAssoc[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)
+}
+
+object Test extends App {
+ {
+ @inline implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x)
+ val x = 1 -> "abc"
+ println(x)
+ }
+
+ {
+ val y = 2 -> "def"
+ println(y)
+ }
+}
diff --git a/test/files/run/primitive-sigs-2.check b/test/files/run/primitive-sigs-2.check
index 0af1434cea..feb0619525 100644
--- a/test/files/run/primitive-sigs-2.check
+++ b/test/files/run/primitive-sigs-2.check
@@ -1,4 +1,4 @@
-T<java.lang.Object> class java.lang.Object
+T<java.lang.Object>
List(A, char, class java.lang.Object)
a
public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.Manifest<T>)
diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check
index b5a54f5ea7..d16e2c5178 100644
--- a/test/files/run/programmatic-main.check
+++ b/test/files/run/programmatic-main.check
@@ -4,8 +4,8 @@
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
- extmethods 5 add extension methods for inline classes
- superaccessors 6 add super accessors in traits and nested classes
+ superaccessors 5 add super accessors in traits and nested classes
+ extmethods 6 add extension methods for inline classes
pickler 7 serialize symbol tables
refchecks 8 reference/override checking, translate nested objects
uncurry 9 uncurry, translate function values to anonymous classes
@@ -13,17 +13,18 @@
specialize 11 @specialized-driven class and method specialization
explicitouter 12 this refs to outer pointers, translate patterns
erasure 13 erase types, add interfaces for traits
- lazyvals 14 allocate bitmaps, translate lazy vals into lazified defs
- lambdalift 15 move nested functions to top level
- constructors 16 move field definitions into constructors
- flatten 17 eliminate inner classes
- mixin 18 mixin composition
- cleanup 19 platform-specific cleanups, generate reflective calls
- icode 20 generate portable intermediate code
- inliner 21 optimization: do inlining
-inlineExceptionHandlers 22 optimization: inline exception handlers
- closelim 23 optimization: eliminate uncalled closures
- dce 24 optimization: eliminate dead code
- jvm 25 generate JVM bytecode
- terminal 26 The last phase in the compiler chain
+ posterasure 14 clean up erased inline classes
+ lazyvals 15 allocate bitmaps, translate lazy vals into lazified defs
+ lambdalift 16 move nested functions to top level
+ constructors 17 move field definitions into constructors
+ flatten 18 eliminate inner classes
+ mixin 19 mixin composition
+ cleanup 20 platform-specific cleanups, generate reflective calls
+ icode 21 generate portable intermediate code
+ inliner 22 optimization: do inlining
+inlineExceptionHandlers 23 optimization: inline exception handlers
+ closelim 24 optimization: eliminate uncalled closures
+ dce 25 optimization: eliminate dead code
+ jvm 26 generate JVM bytecode
+ terminal 27 The last phase in the compiler chain
diff --git a/test/files/run/t4110.check b/test/files/run/t4110.check
index dea7e5957c..8b005989de 100644
--- a/test/files/run/t4110.check
+++ b/test/files/run/t4110.check
@@ -1,2 +1,2 @@
-Object with Test$A with Test$B with Object
-Object with Test$A with Test$B with Object
+Object with Test$A with Test$B
+Object with Test$A with Test$B
diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check
index b94da0c9d8..da467e27ea 100644
--- a/test/files/run/t4172.check
+++ b/test/files/run/t4172.check
@@ -4,7 +4,7 @@ Type :help for more information.
scala>
scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) }
-c: (C, C with Object{def f: Int}) forSome { type C <: Object } = (C,C)
+c: (C, C{def f: Int}) forSome { type C <: Object } = (C,C)
scala>
diff --git a/test/files/run/valueclasses-constr.check b/test/files/run/valueclasses-constr.check
new file mode 100644
index 0000000000..df37fbc723
--- /dev/null
+++ b/test/files/run/valueclasses-constr.check
@@ -0,0 +1,2 @@
+0
+00:16:40
diff --git a/test/files/run/valueclasses-constr.scala b/test/files/run/valueclasses-constr.scala
new file mode 100644
index 0000000000..7a10299386
--- /dev/null
+++ b/test/files/run/valueclasses-constr.scala
@@ -0,0 +1,25 @@
+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)
+}
+
+object Test extends App {
+
+ val y: TOD = new TOD(1000)
+ val x: TOD = TOD(1000)
+ println(x.hours)
+ println(x)
+}
+