diff options
author | Ruediger Klaehn <rklaehn@gmail.com> | 2012-08-21 00:08:03 +0200 |
---|---|---|
committer | Ruediger Klaehn <rklaehn@gmail.com> | 2012-08-21 00:08:03 +0200 |
commit | d78ef8f0703ccdd091e42e874967ec7db5ce08f5 (patch) | |
tree | 8b350b24b95f9c025fae8cac478f6e56f36c108d /test/files | |
parent | ebf17362b58ad52f81c7968523293371f92daa90 (diff) | |
download | scala-d78ef8f0703ccdd091e42e874967ec7db5ce08f5.tar.gz scala-d78ef8f0703ccdd091e42e874967ec7db5ce08f5.tar.bz2 scala-d78ef8f0703ccdd091e42e874967ec7db5ce08f5.zip |
Added test that tests that correct classes are being created when removing elements
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t6261.scala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/files/run/t6261.scala b/test/files/run/t6261.scala new file mode 100644 index 0000000000..873875285d --- /dev/null +++ b/test/files/run/t6261.scala @@ -0,0 +1,32 @@ +import scala.collection.immutable._ + +object Test extends App { + + def test1() { + // test that a HashTrieMap with one leaf element is not created! + val x = HashMap.empty + (1->1) + (2->2) + if(x.getClass.getSimpleName != "HashTrieMap") + println("A hash map containing two non-colliding values should be a HashTrieMap") + + val y = x - 1 + if(y.getClass.getSimpleName != "HashMap1") + println("A hash map containing one element should always use HashMap1") + } + + def test2() { + // class that always causes hash collisions + case class Collision(value:Int) { override def hashCode = 0 } + + // create a set that should have a collison + val x = HashMap.empty + (Collision(0)->0) + (Collision(1) ->0) + if(x.getClass.getSimpleName != "HashMapCollision1") + println("HashMap of size >1 with collisions should use HashMapCollision") + + // remove the collision again by removing all but one element + val y = x - Collision(0) + if(y.getClass.getSimpleName != "HashMap1") + println("HashMap of size 1 should use HashMap1" + y.getClass) + } + test1() + test2() +} |