You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: kotlinx-collections-immutable/src/main/kotlin/kotlinx/collections/immutable/implementations/persistentOrderedMap/PersistentOrderedMap.kt
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ internal class PersistentOrderedMap<K, V>(
86
86
87
87
val links = hashMap[key]
88
88
if (links !=null) {
89
-
if (links.value == value) {
89
+
if (links.value === value) {
90
90
returnthis
91
91
}
92
92
val newMap = hashMap.put(key, links.withValue(value))
Copy file name to clipboardExpand all lines: kotlinx-collections-immutable/tests/src/test/kotlin/kotlinx.collections.immutable/contractTests/immutableMap/ImmutableMapTest.kt
+19-6Lines changed: 19 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ abstract class ImmutableMapTest {
60
60
val empty2 = immutableMapOf<String, Int>()
61
61
assertEquals<ImmutableMap<*, *>>(empty1, empty2)
62
62
assertEquals(mapOf<Int, String>(), empty1)
63
-
assertTrue(empty1=== empty2)
63
+
assertSame<ImmutableMap<*, *>>(empty1, empty2)
64
64
65
65
compareMaps(emptyMap(), empty1)
66
66
}
@@ -85,7 +85,7 @@ abstract class ImmutableMapTest {
85
85
val map =HashMap(original) // copy
86
86
var immMap = map.toPersistentMap()
87
87
val immMap2 = immMap.toImmutableMap()
88
-
assertTrue(immMap2=== immMap)
88
+
assertSame(immMap2, immMap)
89
89
90
90
compareMapsUnordered(original, immMap)
91
91
compareMapsUnordered(map, immMap)
@@ -115,6 +115,19 @@ abstract class ImmutableMapTest {
115
115
assertEquals(mapOf("x" to null, "y" to 1, "x!" to null, "y!" to 1), map)
116
116
}
117
117
118
+
@Test funputEqualButNotSameValue() {
119
+
data classValue<T>(valvalue:T)
120
+
val map = immutableMapOf("x" to Value(1))
121
+
122
+
val newValue =Value(1)
123
+
val newMap = map.put("x", newValue)
124
+
assertNotSame(map, newMap)
125
+
assertEquals(map, newMap)
126
+
127
+
val sameMap = newMap.put("x", newValue)
128
+
assertSame(newMap, sameMap)
129
+
}
130
+
118
131
@Test funremoveElements() {
119
132
val map = immutableMapOf("x" to 1, null to "x").toPersistentMap()
120
133
@@ -149,10 +162,10 @@ abstract class ImmutableMapTest {
149
162
"abcxaxyz12".associateTo(builder) { it to it.toInt() }
150
163
val map = builder.build()
151
164
assertEquals<Map<*, *>>(map, builder)
152
-
assertTrue(map=== builder.build(), "Building the same list without modifications")
165
+
assertSame(map, builder.build(), "Building the same list without modifications")
0 commit comments