1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
object Test extends App {
import collection.mutable.ListBuffer
def newLB = ListBuffer('a, 'b, 'c, 'd, 'e)
val lb0 = newLB
try {
lb0.insert(9, 'x)
} catch {
case ex: IndexOutOfBoundsException => println(ex)
}
val lb1 = newLB
try {
lb1.insert(9, 'x)
} catch {
case ex: IndexOutOfBoundsException =>
}
val replStr = scala.runtime.ScalaRunTime.replStringOf(lb1, 100)
if (replStr == "ListBuffer('a, 'b, 'c, 'd, 'e)\n")
println("replStringOf OK")
else
println("replStringOf FAILED: " + replStr)
val len = lb1.length
if (len == 5)
println("length OK")
else
println("length FAILED: " + len)
}
|