diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-04-01 16:47:22 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-04-01 16:47:22 +0200 |
commit | dcd9a83916f9e0128ef6869def82d4f23bdea0e0 (patch) | |
tree | e58331aebe8ba06fd1c15faf36fdbb3f77b489b9 /test/files/scalacheck | |
parent | ebf0976c363c67e6a46c66d70b39704f1ce5e74a (diff) | |
parent | fcc20fe4d3ac5caceb50965bc202b880e61f984c (diff) | |
download | scala-dcd9a83916f9e0128ef6869def82d4f23bdea0e0.tar.gz scala-dcd9a83916f9e0128ef6869def82d4f23bdea0e0.tar.bz2 scala-dcd9a83916f9e0128ef6869def82d4f23bdea0e0.zip |
Merge commit 'fcc20fe' into merge/2.11-to-2.12-apr-1
Diffstat (limited to 'test/files/scalacheck')
-rw-r--r-- | test/files/scalacheck/Ctrie.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/scalacheck/Ctrie.scala b/test/files/scalacheck/Ctrie.scala index 714f1c3b09..eef9d06f37 100644 --- a/test/files/scalacheck/Ctrie.scala +++ b/test/files/scalacheck/Ctrie.scala @@ -186,6 +186,25 @@ object Test extends Properties("concurrent.TrieMap") { }) } + property("concurrent getOrElseUpdate") = forAll(threadCounts, sizes) { + (p, sz) => + val totalInserts = new java.util.concurrent.atomic.AtomicInteger + val ct = new TrieMap[Wrap, String] + + val results = inParallel(p) { + idx => + (0 until sz) foreach { + i => + val v = ct.getOrElseUpdate(Wrap(i), idx + ":" + i) + if (v == idx + ":" + i) totalInserts.incrementAndGet() + } + } + + (totalInserts.get == sz) && ((0 until sz) forall { + case i => ct(Wrap(i)).split(":")(1).toInt == i + }) + } + } |