summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-06-06 13:18:05 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-06-06 13:18:05 -0700
commit2023f3d2d95c37e7fff1b367e708bb509516f5d8 (patch)
tree8eb217fb55c7df7ec21faf9ec6811e68a8f0ce9d /test/files/run
parent0cab12a04689a6e062891c293ab5db2374414134 (diff)
parentdaca24d8e7050eab9551b123cef010d7bf33f803 (diff)
downloadscala-2023f3d2d95c37e7fff1b367e708bb509516f5d8.tar.gz
scala-2023f3d2d95c37e7fff1b367e708bb509516f5d8.tar.bz2
scala-2023f3d2d95c37e7fff1b367e708bb509516f5d8.zip
Merge pull request #673 from axel22/issue/5880
Fix SI-5880.
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/t5880.scala41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/files/run/t5880.scala b/test/files/run/t5880.scala
new file mode 100644
index 0000000000..08cd0d6bf8
--- /dev/null
+++ b/test/files/run/t5880.scala
@@ -0,0 +1,41 @@
+
+
+import scala.collection.JavaConversions._
+
+
+
+object Test {
+
+ def main(args:Array[String]) = {
+ val tests = 5000
+ val jm: java.util.Map[Int, Int] = scala.collection.mutable.Map((0 until tests) zip (0 until tests).reverse: _*)
+ val es = jm.entrySet()
+ val it = es.iterator
+
+ // chi square test
+ val groups = 10
+ val hits = new Array[Int](groups)
+ def hit(hc: Int) {
+ val bucket = math.abs(hc) / (Int.MaxValue / groups)
+ hits(bucket) += 1
+ }
+ def expected = tests / groups
+ def Dstat = {
+ val diffs = for (i <- 0 until groups) yield math.abs(hits(i) - expected)
+ diffs.sum.toDouble / expected
+ }
+ def ChiSquare = {
+ val diffs = for (i <- 0 until groups) yield (hits(i) - expected) * (hits(i) - expected)
+ diffs.sum.toDouble / expected
+ }
+
+ while (it.hasNext) {
+ val x = it.next()
+ hit(x.##)
+ }
+ // println(hits.toBuffer)
+ // println(ChiSquare)
+ assert(ChiSquare < 2.0)
+ }
+
+}