diff options
author | Paul Phillips <paulp@improving.org> | 2011-08-24 17:11:55 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-08-24 17:11:55 +0000 |
commit | b9785280a7138a2bb52060faf94807aa0d07dec1 (patch) | |
tree | 870cc1930ac3d50cd07078260f58984224dd39a5 /test/files/run/t978.scala | |
parent | 84fcf633d9ca507124806d64729cb8463bcebb69 (diff) | |
download | scala-b9785280a7138a2bb52060faf94807aa0d07dec1.tar.gz scala-b9785280a7138a2bb52060faf94807aa0d07dec1.tar.bz2 scala-b9785280a7138a2bb52060faf94807aa0d07dec1.zip |
Renamed tests named bugXXX to tXXX, no review.
Diffstat (limited to 'test/files/run/t978.scala')
-rw-r--r-- | test/files/run/t978.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/files/run/t978.scala b/test/files/run/t978.scala new file mode 100644 index 0000000000..3ffac92761 --- /dev/null +++ b/test/files/run/t978.scala @@ -0,0 +1,38 @@ +class Foo(val n: Int) { + override def hashCode = n % 2 // pretty bad hash + override def equals(other: Any): Boolean = other match { + case f: Foo => f.n == n + case _ => false + } + + override def toString = "" + n +} + +object Test extends App { + val set = new collection.mutable.HashSet[Foo] +// val set = new collection.jcl.HashSet[Foo] + + val max = 200 + for (x <- 1 to max) + set += new Foo(x) + + testRemove(2) + testExists(2) + + def testRemove(m: Int) { + for (x <- 1 to max; if x % m == 0) { + val f = new Foo(x) + set -= f + assert(!(set contains f)) + testExists(m) + } + } + + def testExists(m: Int) { + for (x <- 1 to max; if x % m == 1) { + val f = new Foo(x) + assert(set contains f, "For element: " + f + " set: " + set) + } + } + +} |