[K/N] Any.isFrozen is now always false when freezing is disabled

This commit is contained in:
Pavel Kunyavskiy
2022-01-19 16:15:20 +03:00
committed by Space
parent 35ef8cc6da
commit 3798920183
20 changed files with 116 additions and 50 deletions
@@ -93,10 +93,12 @@ fun test4() {
ref.compareAndSwap(null, Data(2))
assertEquals(2, ref.value!!.value)
}
run {
val ref = AtomicReference<Data?>(null).freeze()
assertFailsWith<InvalidMutabilityException> {
ref.compareAndSwap(null, Data(2))
if (Platform.isFreezingEnabled) {
run {
val ref = AtomicReference<Data?>(null).freeze()
assertFailsWith<InvalidMutabilityException> {
ref.compareAndSwap(null, Data(2))
}
}
}
}
@@ -137,11 +139,13 @@ fun test7() {
ref.value = Array(1) { "po" }
assertEquals(ref.value[0], "po")
ref.freeze()
assertFailsWith<InvalidMutabilityException> {
ref.value = Array(1) { "no" }
}
assertFailsWith<InvalidMutabilityException> {
ref.value[0] = "go"
if (Platform.isFreezingEnabled) {
assertFailsWith<InvalidMutabilityException> {
ref.value = Array(1) { "no" }
}
assertFailsWith<InvalidMutabilityException> {
ref.value[0] = "go"
}
}
ref.value = Array(1) { "so" }.freeze()
assertEquals(ref.value[0], "so")
@@ -81,9 +81,11 @@ private val checkedLazyModes =
@Test fun runTest3() {
for (mode in checkedLazyModes) {
assertFailsWith<InvalidMutabilityException> {
println(Lazy(mode).freezer)
if (Platform.isFreezingEnabled) {
for (mode in checkedLazyModes) {
assertFailsWith<InvalidMutabilityException> {
println(Lazy(mode).freezer)
}
}
}
}