diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2017-02-16 12:29:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-16 12:29:04 -0800 |
commit | 813324a8e733c11ed603de4597a7e9e34051eca9 (patch) | |
tree | 30147a1359f6d30e3373b5daa43dcf54a92e31ed /test/junit/scala | |
parent | e2be7c498dd849a007ab3e2a923fe48c8ae74b94 (diff) | |
parent | d1dbf1864c4853854701c1b0c51c0e5e21eda9d8 (diff) | |
download | scala-813324a8e733c11ed603de4597a7e9e34051eca9.tar.gz scala-813324a8e733c11ed603de4597a7e9e34051eca9.tar.bz2 scala-813324a8e733c11ed603de4597a7e9e34051eca9.zip |
Merge pull request #5687 from retronym/ticket/10177
SI-10177 Override lazy operations to preserve TrieMap's semantics
Diffstat (limited to 'test/junit/scala')
-rw-r--r-- | test/junit/scala/collection/concurrent/TrieMapTest.scala | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/junit/scala/collection/concurrent/TrieMapTest.scala b/test/junit/scala/collection/concurrent/TrieMapTest.scala new file mode 100644 index 0000000000..ed67f3e9a9 --- /dev/null +++ b/test/junit/scala/collection/concurrent/TrieMapTest.scala @@ -0,0 +1,54 @@ +package scala.collection.concurrent + +import org.junit.{Assert, Test} + +class TrieMapTest { + + private def check[T](result2: List[Any])(f: TrieMap[String, String] => TraversableOnce[Any]) = { + val m = TrieMap[String, String]() + val values = f(m) + m.put("k", "v") + Assert.assertEquals(Nil, values.toList) + Assert.assertEquals(result2, f(m).toList) + } + + @Test + def iterator(): Unit = { + check(List(("k", "v")))(_.iterator) + } + + @Test + def values(): Unit = { + check(List("v"))(_.values) + } + + @Test + def valuesIterator(): Unit = { + check(List("v"))(_.valuesIterator) + } + + @Test + def keySet(): Unit = { + check(List("k"))(_.keySet) + } + + @Test + def keysIterator(): Unit = { + check(List("k"))(_.keysIterator) + } + + @Test + def keys(): Unit = { + check(List("k"))(_.keys) + } + + @Test + def filterKeys(): Unit = { + check(List(("k", "v")))(_.filterKeys(_ => true)) + } + + @Test + def mapValues(): Unit = { + check(List(("k", "v")))(_.mapValues(x => x)) + } +} |