diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t5867.check | 1 | ||||
-rw-r--r-- | test/files/run/t5867.scala | 14 | ||||
-rw-r--r-- | test/files/run/t5879.check | 16 | ||||
-rw-r--r-- | test/files/run/t5879.scala | 74 |
4 files changed, 105 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)) + } + +} |