summaryrefslogtreecommitdiff
path: root/test/files/run/t6632.scala
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2014-02-13 17:47:27 -0800
committerRex Kerr <ichoran@gmail.com>2014-02-13 17:47:27 -0800
commitd3a302b022adc5eaeb1fcbdffaffd5fd438726e0 (patch)
tree8f11e757d17d29e13e106bd7426591c8813ed610 /test/files/run/t6632.scala
parentc83e01d47d941265fa5415c0f29a884c904fdfa0 (diff)
downloadscala-d3a302b022adc5eaeb1fcbdffaffd5fd438726e0.tar.gz
scala-d3a302b022adc5eaeb1fcbdffaffd5fd438726e0.tar.bz2
scala-d3a302b022adc5eaeb1fcbdffaffd5fd438726e0.zip
SI-6632 ListBuffer's updated accepts negative positions
Changed the behavior in SeqLike.updated (which would silently accept negatives and throw on empty.tail) to throw IndexOutOfBoundException. Updated tests to verify the behavior in ListBuffer. Everything else SeqLike will come along for the ride.
Diffstat (limited to 'test/files/run/t6632.scala')
-rw-r--r--test/files/run/t6632.scala29
1 files changed, 11 insertions, 18 deletions
diff --git a/test/files/run/t6632.scala b/test/files/run/t6632.scala
index 0242e60104..f338b73fa6 100644
--- a/test/files/run/t6632.scala
+++ b/test/files/run/t6632.scala
@@ -3,27 +3,20 @@ object Test extends App {
def newLB = ListBuffer('a, 'b, 'c, 'd, 'e)
- val lb0 = newLB
+ def iiobe[A](f: => A) =
+ try { f }
+ catch { case ex: IndexOutOfBoundsException => println(ex) }
- try {
- lb0.insert(-1, 'x)
- } catch {
- case ex: IndexOutOfBoundsException => println(ex)
- }
+ val lb0 = newLB
+ iiobe( lb0.insert(-1, 'x) )
val lb1 = newLB
-
- try {
- lb1.insertAll(-2, Array('x, 'y, 'z))
- } catch {
- case ex: IndexOutOfBoundsException => println(ex)
- }
+ iiobe( lb1.insertAll(-2, Array('x, 'y, 'z)) )
val lb2 = newLB
+ iiobe( lb2.update(-3, 'u) )
- try {
- lb2.update(-3, 'u)
- } catch {
- case ex: IndexOutOfBoundsException => println(ex)
- }
-} \ No newline at end of file
+ val lb3 = newLB
+ iiobe( lb3.updated(-1, 'u) )
+ iiobe( lb3.updated(5, 'u) )
+}