diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-02-09 23:02:29 +0100 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-02-09 23:02:29 +0100 |
commit | 08a30e89ef10f1ef9f29b754b61ca7593d475f64 (patch) | |
tree | f5995e99f8cf8aa91970ccbb04933f943f0f3db4 /test | |
parent | 9dc60af28e2c17579c17e27168d1e29ef34efaef (diff) | |
parent | 2dfbbf55688d17fd3daa15341da878b98783ba3c (diff) | |
download | scala-08a30e89ef10f1ef9f29b754b61ca7593d475f64.tar.gz scala-08a30e89ef10f1ef9f29b754b61ca7593d475f64.tar.bz2 scala-08a30e89ef10f1ef9f29b754b61ca7593d475f64.zip |
Merge pull request #3371 from Ichoran/issue/8154
AnyRefMap iterates its way to ((null, null))
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/collection/SetMapConsistencyTest.scala | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/junit/scala/collection/SetMapConsistencyTest.scala b/test/junit/scala/collection/SetMapConsistencyTest.scala index 7bb8ca958b..0d6f43db06 100644 --- a/test/junit/scala/collection/SetMapConsistencyTest.scala +++ b/test/junit/scala/collection/SetMapConsistencyTest.scala @@ -478,7 +478,7 @@ class SetMapConsistencyTest { } @Test - def si8213() { + def testSI8213() { val am = new scala.collection.mutable.AnyRefMap[String, Int] for (i <- 0 until 1024) am += i.toString -> i am.getOrElseUpdate("1024", { am.clear; -1 }) @@ -488,4 +488,23 @@ class SetMapConsistencyTest { lm.getOrElseUpdate(1024, { lm.clear; -1 }) assert(lm == scala.collection.mutable.LongMap(1024L -> -1)) } + + // Mutating when an iterator is in the wild shouldn't produce random junk in the iterator + // Todo: test all sets/maps this way + @Test + def testSI8154() { + def f() = { + val xs = scala.collection.mutable.AnyRefMap[String, Int]("a" -> 1) + val it = xs.iterator + it.hasNext + xs.clear() + + if (it.hasNext) Some(it.next) + else None + } + assert(f() match { + case Some((a,b)) if (a==null || b==null) => false + case _ => true + }) + } } |