summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t5867.check1
-rw-r--r--test/files/run/t5867.scala14
-rw-r--r--test/files/run/t5879.check16
-rw-r--r--test/files/run/t5879.scala74
-rw-r--r--test/files/run/t5880.scala41
5 files changed, 146 insertions, 0 deletions
diff --git a/test/files/run/t5867.check b/test/files/run/t5867.check
new file mode 100644
index 0000000000..e1811eeefa
--- /dev/null
+++ b/test/files/run/t5867.check
@@ -0,0 +1 @@
+UnrolledBuffer(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50) \ No newline at end of file
diff --git a/test/files/run/t5867.scala b/test/files/run/t5867.scala
new file mode 100644
index 0000000000..6a86ac3e6d
--- /dev/null
+++ b/test/files/run/t5867.scala
@@ -0,0 +1,14 @@
+import collection.mutable.UnrolledBuffer
+
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ val buf = UnrolledBuffer(1 to 50: _*)
+ val dub = buf ++ buf
+
+ println(dub)
+ }
+
+}
diff --git a/test/files/run/t5879.check b/test/files/run/t5879.check
new file mode 100644
index 0000000000..b6cbda35a7
--- /dev/null
+++ b/test/files/run/t5879.check
@@ -0,0 +1,16 @@
+Map(1 -> 1)
+1
+Map(1 -> 1)
+1
+(1,1)
+Map(1 -> 1)
+1
+(1,1)
+Map(1 -> 1)
+1
+(1,2)
+Map(1 -> 2)
+2
+(1,2)
+Map(1 -> 2)
+2 \ No newline at end of file
diff --git a/test/files/run/t5879.scala b/test/files/run/t5879.scala
new file mode 100644
index 0000000000..e1c07fc4c2
--- /dev/null
+++ b/test/files/run/t5879.scala
@@ -0,0 +1,74 @@
+import collection.immutable.HashMap
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ resolveDefault()
+ resolveFirst()
+ resolveSecond()
+ resolveMany()
+ }
+
+ def resolveDefault() {
+ val a = HashMap(1 -> "1")
+ val b = HashMap(1 -> "2")
+
+ val r = a.merged(b)(null)
+ println(r)
+ println(r(1))
+
+ val rold = a.merge(b)
+ println(rold)
+ println(rold(1))
+ }
+
+ def resolveFirst() {
+ val a = HashMap(1 -> "1")
+ val b = HashMap(1 -> "2")
+ def collision(a: (Int, String), b: (Int, String)) = {
+ println(a)
+ a
+ }
+
+ val r = a.merged(b) { collision }
+ println(r)
+ println(r(1))
+
+ val rold = a.merge(b, collision)
+ println(rold)
+ println(rold(1))
+ }
+
+ def resolveSecond() {
+ val a = HashMap(1 -> "1")
+ val b = HashMap(1 -> "2")
+ def collision(a: (Int, String), b: (Int, String)) = {
+ println(b)
+ b
+ }
+
+ val r = a.merged(b) { collision }
+ println(r)
+ println(r(1))
+
+ val rold = a.merge(b, collision)
+ println(rold)
+ println(rold(1))
+ }
+
+ def resolveMany() {
+ val a = HashMap((0 until 100) zip (0 until 100): _*)
+ val b = HashMap((0 until 100) zip (100 until 200): _*)
+ def collision(a: (Int, Int), b: (Int, Int)) = {
+ (a._1, a._2 + b._2)
+ }
+
+ val r = a.merged(b) { collision }
+ for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v))
+
+ val rold = a.merge(b, collision)
+ for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v))
+ }
+
+}
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)
+ }
+
+}