summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/MutableTreeMap.scala
diff options
context:
space:
mode:
authorRui Gonçalves <ruippeixotog@gmail.com>2015-06-26 22:47:18 +0100
committerRui Gonçalves <ruippeixotog@gmail.com>2015-06-26 22:58:38 +0100
commit66bdc5200f5270f4064c6b92192a43db34136714 (patch)
tree95484a5058ac0ec81e2e1698edea07f54fd597e5 /test/files/scalacheck/MutableTreeMap.scala
parentd90d8b89687be5c817cc081ed970328c6d8fd13f (diff)
downloadscala-66bdc5200f5270f4064c6b92192a43db34136714.tar.gz
scala-66bdc5200f5270f4064c6b92192a43db34136714.tar.bz2
scala-66bdc5200f5270f4064c6b92192a43db34136714.zip
Fix size update on `mutable.TreeMap#clear()`
The previous implementation has a major bug - although `clear()` sets the root node to `null`, the `size` attribute of the `Tree` was not updated. This effectively meant that even after a `map.clear()`, a call to `map.size` would still yield the old size of the map. The scalacheck test suite was updated to contemplate this issue.
Diffstat (limited to 'test/files/scalacheck/MutableTreeMap.scala')
-rw-r--r--test/files/scalacheck/MutableTreeMap.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/files/scalacheck/MutableTreeMap.scala b/test/files/scalacheck/MutableTreeMap.scala
index ac073b1c42..b072307a63 100644
--- a/test/files/scalacheck/MutableTreeMap.scala
+++ b/test/files/scalacheck/MutableTreeMap.scala
@@ -163,7 +163,7 @@ package scala.collection.mutable {
property("clear") = forAll { (map: mutable.TreeMap[K, V]) =>
map.clear()
- map.isEmpty
+ map.isEmpty && map.size == 0
}
property("serializable") = forAll { (map: mutable.TreeMap[K, V]) =>
@@ -303,7 +303,7 @@ package scala.collection.mutable {
property("clear") = forAll { (map: mutable.TreeMap[K, V], from: Option[K], until: Option[K]) =>
val mapView = map.rangeImpl(from, until)
mapView.clear()
- map.isEmpty && mapView.isEmpty
+ map.isEmpty && mapView.isEmpty && map.size == 0 && mapView.size == 0
}
property("serializable") = forAll { (map: mutable.TreeMap[K, V], from: Option[K], until: Option[K]) =>