diff options
author | Vinicius Miana <vinicius@miana.com.br> | 2013-01-23 22:18:27 -0200 |
---|---|---|
committer | Vinicius Miana <vinicius@miana.com.br> | 2013-01-25 17:56:39 -0200 |
commit | e36327ac2af54e70a391b4dbf036a5e627d65fee (patch) | |
tree | dc25ebaf753d2218f3064062bba02f4893766e3e /test/files | |
parent | 1a63cf8b9b48c98fa754a1eb6dcfe35220016c74 (diff) | |
download | scala-e36327ac2af54e70a391b4dbf036a5e627d65fee.tar.gz scala-e36327ac2af54e70a391b4dbf036a5e627d65fee.tar.bz2 scala-e36327ac2af54e70a391b4dbf036a5e627d65fee.zip |
SI-6853 changed private method remove to be tail recursive.
Operations += and -= on mutable.ListMap rely on the private method remove to perform. This methods was implemented using recursion, but it was not tail recursive. When the ListMap got too big the += caused a StackOverflowError.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t6853.scala | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/files/run/t6853.scala b/test/files/run/t6853.scala new file mode 100644 index 0000000000..352375c99c --- /dev/null +++ b/test/files/run/t6853.scala @@ -0,0 +1,18 @@ +// Test cases: the only place we can cut and paste without crying +// ourself to sleep. +object Test { + + def main(args: Array[String]): Unit = { + // First testing the basic operations + val m = collection.mutable.ListMap[String, Int]() + var i = 0 + while(i < 2) { m += ("foo" + i) -> i; i = i+1} + assert(m == Map("foo1"->1,"foo0"->0)) + m-= "foo0" + assert(m == Map("foo1"->1)) + // Now checking if it scales as described in SI-6853 + i = 0 + while(i < 80000) { m += ("foo" + i) -> i; i = i+1} + assert(m.size == 80000) + } +} |