diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-01-26 08:37:23 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-01-26 08:37:23 +0000 |
commit | 78a48c46cf3727dd06179cb1360b2f9057647042 (patch) | |
tree | 01f418fab8ee1cd61c5a6a891bdce09cde142098 /test/files/run | |
parent | 78007ac467c9d6e88ae183a9126772829072704c (diff) | |
download | scala-78a48c46cf3727dd06179cb1360b2f9057647042.tar.gz scala-78a48c46cf3727dd06179cb1360b2f9057647042.tar.bz2 scala-78a48c46cf3727dd06179cb1360b2f9057647042.zip |
Merge branch 'work'
Conflicts:
src/library/scala/concurrent/SyncVar.scala
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/UnrolledBuffer.scala | 2 | ||||
-rw-r--r-- | test/files/run/scan.scala | 23 | ||||
-rw-r--r-- | test/files/run/testblock.scala | 33 | ||||
-rw-r--r-- | test/files/run/testpar.scala | 24 |
4 files changed, 81 insertions, 1 deletions
diff --git a/test/files/run/UnrolledBuffer.scala b/test/files/run/UnrolledBuffer.scala index 7e113c3e04..62a1f7d083 100644 --- a/test/files/run/UnrolledBuffer.scala +++ b/test/files/run/UnrolledBuffer.scala @@ -2,7 +2,7 @@ -import collection.parallel.UnrolledBuffer +import collection.mutable.UnrolledBuffer diff --git a/test/files/run/scan.scala b/test/files/run/scan.scala new file mode 100644 index 0000000000..47e0a7d976 --- /dev/null +++ b/test/files/run/scan.scala @@ -0,0 +1,23 @@ + + + + +object Test { + + def main(args: Array[String]) { + val lst = List(1, 2, 3, 4, 5) + + assert(lst.scanLeft(0)(_ + _) == List(0, 1, 3, 6, 10, 15)) + assert(lst.scanRight(0)(_ + _) == List(15, 14, 12, 9, 5, 0)) + + val emp = List[Int]() + assert(emp.scanLeft(0)(_ + _) == List(0)) + assert(emp.scanRight(0)(_ + _) == List(0)) + + val stream = Stream(1, 2, 3, 4, 5) + assert(stream.scanLeft(0)(_ + _) == Stream(0, 1, 3, 6, 10, 15)) + + assert(Stream.from(1).scanLeft(0)(_ + _).take(5) == Stream(0, 1, 3, 6, 10)) + } + +}
\ No newline at end of file diff --git a/test/files/run/testblock.scala b/test/files/run/testblock.scala new file mode 100644 index 0000000000..a334b668fd --- /dev/null +++ b/test/files/run/testblock.scala @@ -0,0 +1,33 @@ + + + + +import scala.parallel._ + + + + +object Test { + + def main(args: Array[String]) { + if (util.Properties.isJavaAtLeast("1.6")) { + val vendor = util.Properties.javaVmVendor + if ((vendor contains "Sun") || (vendor contains "Apple")) blockcomp(10) + } + } + + val lock = new java.util.concurrent.locks.ReentrantLock + + def blockcomp(n: Int): Unit = if (n > 0) { + val (x, y) = par(blockcomp(n - 1), blockcomp(n - 1)) + if (n == 8) blocking { // without this blocking block, deadlock occurs + lock.lock() + } + x() + y() + if (n == 8) { + lock.unlock() + } + } + +} diff --git a/test/files/run/testpar.scala b/test/files/run/testpar.scala new file mode 100644 index 0000000000..c4c813ee00 --- /dev/null +++ b/test/files/run/testpar.scala @@ -0,0 +1,24 @@ + + + +import scala.parallel._ + + + + + +object Test { + + def main(args: Array[String]) { + if (util.Properties.isJavaAtLeast("1.6")) { + val vendor = util.Properties.javaVmVendor + if ((vendor contains "Sun") || (vendor contains "Apple")) assert(fib(40) == 102334155) + } + } + + def fib(n: Int): Int = if (n < 3) 1 else if (n < 35) fib(n - 1) + fib(n - 2) else { + val (p, pp) = par(fib(n - 1), fib(n - 2)) + p() + pp() + } + +} |