[K/N] Test for freezing disabling
This commit is contained in:
@@ -1216,6 +1216,15 @@ standaloneTest("freeze6") {
|
||||
testLogger = KonanTest.Logger.SILENT
|
||||
}
|
||||
|
||||
standaloneTest("freeze_disabled") {
|
||||
enabled = (project.testTarget != 'wasm32') && // No exceptions on WASM.
|
||||
!isNoopGC && isExperimentalMM
|
||||
flags = ["-tr"]
|
||||
source = "runtime/workers/freeze_disabled.kt"
|
||||
testLogger = KonanTest.Logger.SILENT
|
||||
}
|
||||
|
||||
|
||||
task atomic0(type: KonanLocalTest) {
|
||||
enabled = (project.testTarget != 'wasm32') // Workers need pthreads.
|
||||
useGoldenData = true
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package runtime.workers.freeze_disabled
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
// this test is ran with disabled freezing, so no mutability checks are done
|
||||
|
||||
class A(var x:Int)
|
||||
|
||||
@Test
|
||||
fun testClassNotFrozen(){
|
||||
val a = A(1)
|
||||
a.freeze()
|
||||
a.x = 2
|
||||
assertEquals(a.x, 2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testArrayNotFrozen(){
|
||||
val a = arrayOf(1, 2, 3, 4, 5)
|
||||
a.freeze()
|
||||
a[0] = 6
|
||||
assertEquals(a[0], 6)
|
||||
}
|
||||
Reference in New Issue
Block a user