Skip to content

Commit d67e597

Browse files
qwwdfsadrecheej
authored andcommitted
Fix sporadic ConcurrentWeakMapTest failures (Kotlin#2187)
1 parent 2d1740a commit d67e597

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapTest.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import org.junit.*
1212
class ConcurrentWeakMapTest : TestBase() {
1313
@Test
1414
fun testSimple() {
15-
val expect = (1..1000).associateWith { it.toString() }
16-
val m = ConcurrentWeakMap<Int, String>()
15+
val expect = (1..1000).associate { it.toString().let { it to it } }
16+
val m = ConcurrentWeakMap<String, String>()
1717
// repeat adding/removing a few times
1818
repeat(5) {
1919
assertEquals(0, m.size)
@@ -27,7 +27,7 @@ class ConcurrentWeakMapTest : TestBase() {
2727
assertEquals(expect.keys, m.keys)
2828
assertEquals(expect.entries, m.entries)
2929
for ((k, v) in expect) {
30-
assertEquals(v, m.get(k))
30+
assertEquals(v, m[k])
3131
}
3232
assertEquals(expect.size, m.size)
3333
if (it % 2 == 0) {
@@ -38,9 +38,9 @@ class ConcurrentWeakMapTest : TestBase() {
3838
m.clear()
3939
}
4040
assertEquals(0, m.size)
41-
for ((k, v) in expect) {
42-
assertNull(m.get(k))
41+
for ((k, _) in expect) {
42+
assertNull(m[k])
4343
}
4444
}
4545
}
46-
}
46+
}

0 commit comments

Comments
 (0)