diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2012-11-09 03:18:33 +0100 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2012-11-09 21:44:22 +0100 |
commit | 925c6e34635a9a8621b20c328670cbd23975327f (patch) | |
tree | c3340b8d75c2be2fa2dd3970e062c9694f30aa95 /test/files | |
parent | 3b68b45a200087104a1ac2de7c4b86635023fd4d (diff) | |
download | scala-925c6e34635a9a8621b20c328670cbd23975327f.tar.gz scala-925c6e34635a9a8621b20c328670cbd23975327f.tar.bz2 scala-925c6e34635a9a8621b20c328670cbd23975327f.zip |
SI-6632 SI-6633 Fixes issues and data corruption in ListBuffer
- Disallow negative positions for ListBuffer#insert/insertAll/update
- Fix data corruption issue in ListBuffer#insert
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t6632.check | 3 | ||||
-rw-r--r-- | test/files/run/t6632.scala | 29 | ||||
-rw-r--r-- | test/files/run/t6633.check | 3 | ||||
-rw-r--r-- | test/files/run/t6633.scala | 33 |
4 files changed, 68 insertions, 0 deletions
diff --git a/test/files/run/t6632.check b/test/files/run/t6632.check new file mode 100644 index 0000000000..1f084b1dac --- /dev/null +++ b/test/files/run/t6632.check @@ -0,0 +1,3 @@ +java.lang.IndexOutOfBoundsException: -1 +java.lang.IndexOutOfBoundsException: -2 +java.lang.IndexOutOfBoundsException: -3 diff --git a/test/files/run/t6632.scala b/test/files/run/t6632.scala new file mode 100644 index 0000000000..c1c8d4abe0 --- /dev/null +++ b/test/files/run/t6632.scala @@ -0,0 +1,29 @@ +object Test extends App { + import collection.mutable.ListBuffer + + def newLB = ListBuffer('a, 'b, 'c, 'd, 'e) + + val lb0 = newLB + + try { + lb0.insert(-1, 'x) + } catch { + case ex: IndexOutOfBoundsException => println(ex) + } + + val lb1 = newLB + + try { + lb1.insertAll(-2, Array('x, 'y, 'z)) + } catch { + case ex: IndexOutOfBoundsException => println(ex) + } + + val lb2 = newLB + + try { + lb2.update(-3, 'u) + } catch { + case ex: IndexOutOfBoundsException => println(ex) + } +}
\ No newline at end of file diff --git a/test/files/run/t6633.check b/test/files/run/t6633.check new file mode 100644 index 0000000000..1ff8cdbc44 --- /dev/null +++ b/test/files/run/t6633.check @@ -0,0 +1,3 @@ +java.lang.IndexOutOfBoundsException: 9 +replStringOf OK +length OK diff --git a/test/files/run/t6633.scala b/test/files/run/t6633.scala new file mode 100644 index 0000000000..bd993c8d88 --- /dev/null +++ b/test/files/run/t6633.scala @@ -0,0 +1,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) +}
\ No newline at end of file |