diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/hashCodeScalaRunTime.scala (renamed from test/files/run/hashCodeBoxesRunTime.scala) | 10 | ||||
-rw-r--r-- | test/files/run/hashhash.scala | 13 | ||||
-rw-r--r-- | test/files/run/lazy-locals.check | 41 | ||||
-rw-r--r-- | test/files/run/lazy-locals.scala | 85 | ||||
-rw-r--r-- | test/files/run/t1247.check | 1 | ||||
-rw-r--r-- | test/files/run/t1247.scala | 11 | ||||
-rw-r--r-- | test/files/run/t3569.check | 3 | ||||
-rw-r--r-- | test/files/run/t4190.check | 3 | ||||
-rw-r--r-- | test/files/run/t4190.scala | 6 | ||||
-rw-r--r-- | test/files/run/t5201.check | 1 | ||||
-rw-r--r-- | test/files/run/t5201.scala | 8 | ||||
-rw-r--r-- | test/files/run/t5328.check | 3 | ||||
-rw-r--r-- | test/files/run/t5328.scala | 5 |
13 files changed, 122 insertions, 68 deletions
diff --git a/test/files/run/hashCodeBoxesRunTime.scala b/test/files/run/hashCodeScalaRunTime.scala index 081a73376e..e352af95f1 100644 --- a/test/files/run/hashCodeBoxesRunTime.scala +++ b/test/files/run/hashCodeScalaRunTime.scala @@ -1,23 +1,23 @@ -// This only tests direct access to the methods in BoxesRunTime, +// This only tests direct access to the methods in ScalaRunTime, // not the whole scheme. object Test { import java.{ lang => jl } - import scala.runtime.BoxesRunTime.{ hashFromNumber, hashFromObject } + import scala.runtime.ScalaRunTime.{ hash } def allSame[T](xs: List[T]) = assert(xs.distinct.size == 1, "failed: " + xs) def mkNumbers(x: Int): List[Number] = List(x.toByte, x.toShort, x, x.toLong, x.toFloat, x.toDouble) - def testLDF(x: Long) = allSame(List[Number](x, x.toDouble, x.toFloat) map hashFromNumber) + def testLDF(x: Long) = allSame(List[Number](x, x.toDouble, x.toFloat) map hash) def main(args: Array[String]): Unit = { List(Byte.MinValue, -1, 0, 1, Byte.MaxValue) foreach { n => - val hashes = mkNumbers(n) map hashFromNumber + val hashes = mkNumbers(n) map hash allSame(hashes) if (n >= 0) { - val charCode = hashFromObject(n.toChar: Character) + val charCode = hash(n.toChar: Character) assert(charCode == hashes.head) } } diff --git a/test/files/run/hashhash.scala b/test/files/run/hashhash.scala index b9cec99a12..f9fc067398 100644 --- a/test/files/run/hashhash.scala +++ b/test/files/run/hashhash.scala @@ -6,5 +6,18 @@ object Test { /** Just a little sanity check, not to be confused with a unit test. */ List(5, 5.5f, "abc", new AnyRef, ()) foreach confirmSame List(5.0f, 1.0d, -(5.0f), (-1.0d)) foreach confirmDifferent + + val x = (BigInt(1) << 64).toDouble + val y: Any = x + val f: Float = x.toFloat + val jn: java.lang.Number = x + val jf: java.lang.Float = x.toFloat + val jd: java.lang.Double = x + + assert(x.## == y.##, ((x, y))) + assert(x.## == f.##, ((x, f))) + assert(x.## == jn.##, ((x, jn))) + assert(x.## == jf.##, ((x, jf))) + assert(x.## == jd.##, ((x, jd))) } } diff --git a/test/files/run/lazy-locals.check b/test/files/run/lazy-locals.check index 7d14da243b..d1cc754f2c 100644 --- a/test/files/run/lazy-locals.check +++ b/test/files/run/lazy-locals.check @@ -36,30 +36,19 @@ forced lazy val t02 forced lazy val t01 forced lazy val t00 Sum is: 496 -forced lazy val t32 -forced lazy val t31 -forced lazy val t30 -forced lazy val t29 -forced lazy val t28 -forced lazy val t27 -forced lazy val t26 -forced lazy val t25 -forced lazy val t24 -forced lazy val t23 -forced lazy val t22 -forced lazy val t21 -forced lazy val t20 -forced lazy val t19 -forced lazy val t18 -forced lazy val t17 -forced lazy val t16 -forced lazy val t15 -forced lazy val t14 -forced lazy val t13 -forced lazy val t12 -forced lazy val t11 -forced lazy val t10 -forced lazy val t09 +Sum again is: 496 +Sum again again is: 496 +forced lazy val t07 +forced lazy val t06 +forced lazy val t05 +forced lazy val t04 +forced lazy val t03 +forced lazy val t02 +forced lazy val t01 +forced lazy val t00 +Sum is: 28 +Sum again is: 28 +Sum again again is: 28 forced lazy val t08 forced lazy val t07 forced lazy val t06 @@ -69,7 +58,9 @@ forced lazy val t03 forced lazy val t02 forced lazy val t01 forced lazy val t00 -Sum is: 528 +Sum is: 36 +Sum again is: 36 +Sum again again is: 36 forced lazy val t at n = 0 42 forced lazy val t at n = 0 diff --git a/test/files/run/lazy-locals.scala b/test/files/run/lazy-locals.scala index 696aeeba96..aca15d0357 100644 --- a/test/files/run/lazy-locals.scala +++ b/test/files/run/lazy-locals.scala @@ -13,7 +13,7 @@ object Test extends App { 1 + t + t } - /** test 32 lazy vals, which fills one bitmap int. */ + /** test 32 lazy vals, which should spill over multiple byte bitmaps. */ def testLazy32 = { lazy val t00 = { Console.println("forced lazy val t00"); 0 } lazy val t01 = { Console.println("forced lazy val t01"); 1 } @@ -51,12 +51,25 @@ object Test extends App { val sum = t31 + t30 + t29 + t28 + t27 + t26 + t25 + t24 + t23 + t22 + t21 + t20 + t19 + t18 + t17 + t16 + t15 + t14 + t13 + t12 + t11 + t10 + t09 + t08 + t07 + t06 + t05 + - t04 + t03 + t02 + t01 + t00; - println("Sum is: " + sum); + t04 + t03 + t02 + t01 + t00 + val sum2 = t31 + t30 + t29 + t28 + t27 + t26 + t25 + t24 + t23 + + t22 + t21 + t20 + t19 + t18 + t17 + t16 + t15 + t14 + + t13 + t12 + t11 + t10 + t09 + t08 + t07 + t06 + t05 + + t04 + t03 + t02 + t01 + t00 + val sum3 = t00 + t01 + t02 + t03 + t04 + t05 + t06 + t07 + t08 + + t09 + t10 + t11 + t12 + t13 + t14 + t15 + t16 + t17 + + t18 + t19 + t20 + t21 + t22 + t23 + t24 + t25 + t26 + + t27 + t28 + t29 + t30 + t31 + + + + println("Sum is: " + sum) + println("Sum again is: " + sum2) + println("Sum again again is: " + sum3) } - /** test 32 lazy vals, which needs two bitmap ints. */ - def testLazy33 = { + /** test 8 lazy vals, which should fit one byte bitmap. */ + def testLazy8 = { lazy val t00 = { Console.println("forced lazy val t00"); 0 } lazy val t01 = { Console.println("forced lazy val t01"); 1 } lazy val t02 = { Console.println("forced lazy val t02"); 2 } @@ -65,39 +78,38 @@ object Test extends App { lazy val t05 = { Console.println("forced lazy val t05"); 5 } lazy val t06 = { Console.println("forced lazy val t06"); 6 } lazy val t07 = { Console.println("forced lazy val t07"); 7 } - lazy val t08 = { Console.println("forced lazy val t08"); 8 } - lazy val t09 = { Console.println("forced lazy val t09"); 9 } - lazy val t10 = { Console.println("forced lazy val t10"); 10 } - lazy val t11 = { Console.println("forced lazy val t11"); 11 } - lazy val t12 = { Console.println("forced lazy val t12"); 12 } - lazy val t13 = { Console.println("forced lazy val t13"); 13 } - lazy val t14 = { Console.println("forced lazy val t14"); 14 } - lazy val t15 = { Console.println("forced lazy val t15"); 15 } - lazy val t16 = { Console.println("forced lazy val t16"); 16 } - lazy val t17 = { Console.println("forced lazy val t17"); 17 } - lazy val t18 = { Console.println("forced lazy val t18"); 18 } - lazy val t19 = { Console.println("forced lazy val t19"); 19 } - lazy val t20 = { Console.println("forced lazy val t20"); 20 } - lazy val t21 = { Console.println("forced lazy val t21"); 21 } - lazy val t22 = { Console.println("forced lazy val t22"); 22 } - lazy val t23 = { Console.println("forced lazy val t23"); 23 } - lazy val t24 = { Console.println("forced lazy val t24"); 24 } - lazy val t25 = { Console.println("forced lazy val t25"); 25 } - lazy val t26 = { Console.println("forced lazy val t26"); 26 } - lazy val t27 = { Console.println("forced lazy val t27"); 27 } - lazy val t28 = { Console.println("forced lazy val t28"); 28 } - lazy val t29 = { Console.println("forced lazy val t29"); 29 } - lazy val t30 = { Console.println("forced lazy val t30"); 30 } - lazy val t31 = { Console.println("forced lazy val t31"); 31 } - lazy val t32 = { Console.println("forced lazy val t32"); 32 } - val sum = t32 + t31 + t30 + t29 + t28 + t27 + t26 + t25 + t24 + t23 + - t22 + t21 + t20 + t19 + t18 + t17 + t16 + t15 + t14 + - t13 + t12 + t11 + t10 + t09 + t08 + t07 + t06 + t05 + - t04 + t03 + t02 + t01 + t00; - println("Sum is: " + sum); + val sum = t07 + t06 + t05 + t04 + t03 + t02 + t01 + t00 + val sum2 = t07 + t06 + t05 + t04 + t03 + t02 + t01 + t00 + val sum3 = t00 + t01 + t02 + t03 + t04 + t05 + t06 + t07 + + + + println("Sum is: " + sum) + println("Sum again is: " + sum2) + println("Sum again again is: " + sum3) } + /** test 9 lazy vals, which should spill over two bitmaps. */ + def testLazy9 = { + lazy val t00 = { Console.println("forced lazy val t00"); 0 } + lazy val t01 = { Console.println("forced lazy val t01"); 1 } + lazy val t02 = { Console.println("forced lazy val t02"); 2 } + lazy val t03 = { Console.println("forced lazy val t03"); 3 } + lazy val t04 = { Console.println("forced lazy val t04"); 4 } + lazy val t05 = { Console.println("forced lazy val t05"); 5 } + lazy val t06 = { Console.println("forced lazy val t06"); 6 } + lazy val t07 = { Console.println("forced lazy val t07"); 7 } + lazy val t08 = { Console.println("forced lazy val t08"); 8 } + + val sum = t08 + t07 + t06 + t05 + t04 + t03 + t02 + t01 + t00 + val sum2 = t08 + t07 + t06 + t05 + t04 + t03 + t02 + t01 + t00 + val sum3 = t00 + t01 + t02 + t03 + t04 + t05 + t06 + t07 + t08 + + println("Sum is: " + sum) + println("Sum again is: " + sum2) + println("Sum again again is: " + sum3) + } /** test recursive method with lazy vals and a single forced */ def testLazyRec(n: Int): Int = { @@ -185,7 +197,8 @@ object Test extends App { println(testLazy) testLazy32 - testLazy33 + testLazy8 + testLazy9 println(testLazyRec(5)) println(testLazyRecMany(5)) testRecVal diff --git a/test/files/run/t1247.check b/test/files/run/t1247.check new file mode 100644 index 0000000000..ce123032fd --- /dev/null +++ b/test/files/run/t1247.check @@ -0,0 +1 @@ +Is same closure class: true is same closure: true diff --git a/test/files/run/t1247.scala b/test/files/run/t1247.scala new file mode 100644 index 0000000000..c709b73bc8 --- /dev/null +++ b/test/files/run/t1247.scala @@ -0,0 +1,11 @@ +object Test extends App { + val f = () => 5 + def test(g: => Int) { + val gFunc = g _ + val isSameClosureClass = gFunc.getClass == f.getClass + val isSame = gFunc eq f + println("Is same closure class: "+isSameClosureClass+" is same closure: "+isSame) + } + + test(f()) +} diff --git a/test/files/run/t3569.check b/test/files/run/t3569.check index c73fce419a..a9fb5ff32e 100644 --- a/test/files/run/t3569.check +++ b/test/files/run/t3569.check @@ -9,8 +9,7 @@ private int Test$X.var1 private int Test$X.var2 private int Test$X.var3 private int Test$X.x -private volatile int Test$X.bitmap$priv$0 -public volatile int Test$X.bitmap$0 +private volatile byte Test$X.bitmap$0 private final int Test$Y.z1 private final int Test$Y.z2 private int Test$Y.x diff --git a/test/files/run/t4190.check b/test/files/run/t4190.check new file mode 100644 index 0000000000..b8aae0c7a1 --- /dev/null +++ b/test/files/run/t4190.check @@ -0,0 +1,3 @@ +a0 +b0 +c0 diff --git a/test/files/run/t4190.scala b/test/files/run/t4190.scala new file mode 100644 index 0000000000..aa88b8708d --- /dev/null +++ b/test/files/run/t4190.scala @@ -0,0 +1,6 @@ +import collection.mutable._ + +object Test extends App { + val x: ArrayBuffer[String] = ArrayBuffer("a", "b", "c") + x.view map (_ + "0") foreach println +} diff --git a/test/files/run/t5201.check b/test/files/run/t5201.check new file mode 100644 index 0000000000..27ba77ddaf --- /dev/null +++ b/test/files/run/t5201.check @@ -0,0 +1 @@ +true diff --git a/test/files/run/t5201.scala b/test/files/run/t5201.scala new file mode 100644 index 0000000000..48aa7ba54c --- /dev/null +++ b/test/files/run/t5201.scala @@ -0,0 +1,8 @@ +object Test extends App { + // First make sure specific types are preserved + val tmp: Vector[Int] = Vector(Vector(1,2), Vector(3,4)).view.flatten.force + + // Now make sure we really get a view + val seq = Seq(Seq(1, 2), Seq(3, 4)).view.flatten + Console.println(seq.isInstanceOf[collection.SeqView[_,_]]) +} diff --git a/test/files/run/t5328.check b/test/files/run/t5328.check new file mode 100644 index 0000000000..77a43968c5 --- /dev/null +++ b/test/files/run/t5328.check @@ -0,0 +1,3 @@ +2 +1,2,8 +1,8,3 diff --git a/test/files/run/t5328.scala b/test/files/run/t5328.scala new file mode 100644 index 0000000000..12adf45b84 --- /dev/null +++ b/test/files/run/t5328.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(Vector(1).view.updated(0,2).toList mkString ",") + println(Seq(1,2,3).view.updated(2,8).toList mkString ",") + println(List(1,2,3).view.updated(1,8).toList mkString ",") +} |