[K/N] Any.isFrozen is now always false when freezing is disabled
This commit is contained in:
@@ -50,24 +50,26 @@ import kotlin.native.concurrent.*
|
||||
}
|
||||
expect(0) { results.size }
|
||||
|
||||
array.freeze()
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setShortAt(0, 2.toShort())
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setCharAt(0, 'a')
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setIntAt(0, 2)
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setLongAt(0, 2)
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setFloatAt(0, 1.0f)
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setDoubleAt(0, 1.0)
|
||||
if (Platform.isFreezingEnabled) {
|
||||
array.freeze()
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setShortAt(0, 2.toShort())
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setCharAt(0, 'a')
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setIntAt(0, 2)
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setLongAt(0, 2)
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setFloatAt(0, 1.0f)
|
||||
}
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
array.setDoubleAt(0, 1.0)
|
||||
}
|
||||
}
|
||||
println("OK")
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import kotlin.test.*
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlin.native.internal.GC
|
||||
import kotlin.native.*
|
||||
import kotlin.native.ref.WeakReference
|
||||
import kotlin.text.Regex
|
||||
|
||||
@@ -600,6 +601,7 @@ fun createCyclicGarbageFrozen(): Triple<AtomicReference<WorkerBoundReference<B1>
|
||||
|
||||
@Test
|
||||
fun doesNotCollectCyclicGarbageFrozen() {
|
||||
if (!Platform.isFreezingEnabled) return
|
||||
val (ref1Owner, ref1Weak, ref2Weak) = createCyclicGarbageFrozen()
|
||||
|
||||
ref1Owner.value = null
|
||||
@@ -630,6 +632,7 @@ fun createCrossThreadCyclicGarbageFrozen(
|
||||
|
||||
@Test
|
||||
fun doesNotCollectCrossThreadCyclicGarbageFrozen() {
|
||||
if (!Platform.isFreezingEnabled) return
|
||||
val worker = Worker.start()
|
||||
|
||||
val (ref1Owner, ref1Weak, ref2Weak) = createCrossThreadCyclicGarbageFrozen(worker)
|
||||
@@ -674,6 +677,7 @@ fun dispose(refOwner: AtomicReference<WorkerBoundReference<C1>?>) {
|
||||
|
||||
@Test
|
||||
fun doesNotCollectCyclicGarbageWithAtomicsFrozen() {
|
||||
if (!Platform.isFreezingEnabled) return
|
||||
val (ref1Owner, ref1Weak, ref2Weak) = createCyclicGarbageWithAtomicsFrozen()
|
||||
|
||||
ref1Owner.value = null
|
||||
@@ -723,6 +727,7 @@ fun createCrossThreadCyclicGarbageWithAtomicsFrozen(
|
||||
|
||||
@Test
|
||||
fun doesNotCollectCrossThreadCyclicGarbageWithAtomicsFrozen() {
|
||||
if (!Platform.isFreezingEnabled) return
|
||||
val worker = Worker.start()
|
||||
|
||||
val (ref1Owner, ref1Weak, ref2Weak) = createCrossThreadCyclicGarbageWithAtomicsFrozen(worker)
|
||||
@@ -835,6 +840,7 @@ fun testDoubleFreeze() {
|
||||
|
||||
@Test
|
||||
fun testDoubleFreezeWithFreezeBlocker() {
|
||||
if (!Platform.isFreezingEnabled) return
|
||||
val ref = WorkerBoundReference(A(3))
|
||||
val wrapper = Wrapper(ref)
|
||||
wrapper.ensureNeverFrozen()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user