diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-06-04 13:53:13 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-06-08 15:32:17 +0200 |
commit | 7b0f0a142bb526f4bd108a8c208ec9a8952398c9 (patch) | |
tree | ee13d036756be41521a9eb3f1e05898410ab744e /test/instrumented | |
parent | d9103e01b467634d61baa3b131aeb93fca9e20a5 (diff) | |
download | scala-7b0f0a142bb526f4bd108a8c208ec9a8952398c9.tar.gz scala-7b0f0a142bb526f4bd108a8c208ec9a8952398c9.tar.bz2 scala-7b0f0a142bb526f4bd108a8c208ec9a8952398c9.zip |
repairs the tests after the refactoring spree
Diffstat (limited to 'test/instrumented')
-rw-r--r-- | test/instrumented/library/scala/runtime/ScalaRunTime.scala | 32 | ||||
-rw-r--r-- | test/instrumented/srt.patch | 10 |
2 files changed, 25 insertions, 17 deletions
diff --git a/test/instrumented/library/scala/runtime/ScalaRunTime.scala b/test/instrumented/library/scala/runtime/ScalaRunTime.scala index 63908fcc29..f0d452a9be 100644 --- a/test/instrumented/library/scala/runtime/ScalaRunTime.scala +++ b/test/instrumented/library/scala/runtime/ScalaRunTime.scala @@ -14,6 +14,7 @@ import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator } import scala.collection.mutable.WrappedArray import scala.collection.immutable.{ StringLike, NumericRange, List, Stream, Nil, :: } import scala.collection.generic.{ Sorted } +import scala.reflect.{ ArrayTag, ClassTag, arrayTag, classTag } import scala.util.control.ControlThrowable import scala.xml.{ Node, MetaData } @@ -61,7 +62,7 @@ object ScalaRunTime { */ def arrayElementClass(schematic: Any): Class[_] = schematic match { case cls: Class[_] => cls.getComponentType - case tag: ClassTag[_] => tag.erasure + case tag: ClassTag[_] => tag.runtimeClass case tag: ArrayTag[_] => tag.newArray(0).getClass.getComponentType case _ => throw new UnsupportedOperationException("unsupported schematic %s (%s)".format(schematic, if (schematic == null) "null" else schematic.getClass)) } @@ -71,7 +72,7 @@ object ScalaRunTime { * rewrites expressions like 5.getClass to come here. */ def anyValClass[T <: AnyVal : ClassTag](value: T): Class[T] = - classTag[T].erasure.asInstanceOf[Class[T]] + classTag[T].runtimeClass.asInstanceOf[Class[T]] var arrayApplyCount = 0 @@ -142,16 +143,18 @@ object ScalaRunTime { case null => throw new NullPointerException } - /** Convert a numeric value array to an object array. + /** Convert an array to an object array. * Needed to deal with vararg arguments of primitive types that are passed * to a generic Java vararg parameter T ... */ - def toObjectArray(src: AnyRef): Array[Object] = { - val length = array_length(src) - val dest = new Array[Object](length) - for (i <- 0 until length) - array_update(dest, i, array_apply(src, i)) - dest + def toObjectArray(src: AnyRef): Array[Object] = src match { + case x: Array[AnyRef] => x + case _ => + val length = array_length(src) + val dest = new Array[Object](length) + for (i <- 0 until length) + array_update(dest, i, array_apply(src, i)) + dest } def toArray[T](xs: collection.Seq[T]) = { @@ -305,8 +308,12 @@ object ScalaRunTime { */ def stringOf(arg: Any): String = stringOf(arg, scala.Int.MaxValue) def stringOf(arg: Any, maxElements: Int): String = { - def isScalaClass(x: AnyRef) = - Option(x.getClass.getPackage) exists (_.getName startsWith "scala.") + def packageOf(x: AnyRef) = x.getClass.getPackage match { + case null => "" + case p => p.getName + } + def isScalaClass(x: AnyRef) = packageOf(x) startsWith "scala." + def isScalaCompilerClass(x: AnyRef) = packageOf(x) startsWith "scala.tools.nsc." // When doing our own iteration is dangerous def useOwnToString(x: Any) = x match { @@ -322,7 +329,8 @@ object ScalaRunTime { case _: TraversableView[_, _] => true // Don't want to a) traverse infinity or b) be overly helpful with peoples' custom // collections which may have useful toString methods - ticket #3710 - case x: Traversable[_] => !x.hasDefiniteSize || !isScalaClass(x) + // or c) print AbstractFiles which are somehow also Iterable[AbstractFile]s. + case x: Traversable[_] => !x.hasDefiniteSize || !isScalaClass(x) || isScalaCompilerClass(x) // Otherwise, nothing could possibly go wrong case _ => false } diff --git a/test/instrumented/srt.patch b/test/instrumented/srt.patch index 8d08550165..366763e7f9 100644 --- a/test/instrumented/srt.patch +++ b/test/instrumented/srt.patch @@ -1,26 +1,26 @@ 9a10,11 > /* INSTRUMENTED VERSION */ > -43c45,48 +44c46,49 < def isTuple(x: Any) = x != null && tupleNames(x.getClass.getName) --- > var arrayApplyCount = 0 > var arrayUpdateCount = 0 > > def isTuple(x: Any) = tupleNames(x.getClass.getName) -75c80,82 +76c81,83 < def array_apply(xs: AnyRef, idx: Int): Any = xs match { --- > def array_apply(xs: AnyRef, idx: Int): Any = { > arrayApplyCount += 1 > xs match { -87a95 +88a96 > } -90c98,100 +91c99,101 < def array_update(xs: AnyRef, idx: Int, value: Any): Unit = xs match { --- > def array_update(xs: AnyRef, idx: Int, value: Any): Unit = { > arrayUpdateCount += 1 > xs match { -101a112 +102a113 > } |