diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 2177ace052c..48d4d5d938f 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -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 diff --git a/kotlin-native/backend.native/tests/runtime/workers/freeze_disabled.kt b/kotlin-native/backend.native/tests/runtime/workers/freeze_disabled.kt new file mode 100644 index 00000000000..9d4d834e1de --- /dev/null +++ b/kotlin-native/backend.native/tests/runtime/workers/freeze_disabled.kt @@ -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) +}