From e36327ac2af54e70a391b4dbf036a5e627d65fee Mon Sep 17 00:00:00 2001 From: Vinicius Miana Date: Wed, 23 Jan 2013 22:18:27 -0200 Subject: 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. --- test/files/run/t6853.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/files/run/t6853.scala (limited to 'test/files/run') 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) + } +} -- cgit v1.2.3