[K/N] Tests for volatile
^KT-54944
This commit is contained in:
committed by
Space Team
parent
a11f6fd9cb
commit
fc95b88eef
@@ -0,0 +1,25 @@
|
||||
// WITH_STDLIB
|
||||
// IGNORE_BACKEND: WASM, JS
|
||||
// IGNORE_BACKEND_K1: JS_IR
|
||||
// !API_VERSION: 1.9
|
||||
|
||||
import kotlin.concurrent.*
|
||||
|
||||
@OptIn(kotlin.ExperimentalStdlibApi::class)
|
||||
class GenericWrapper<T>(@Volatile var x: T)
|
||||
|
||||
val global = GenericWrapper("FA")
|
||||
val globalLong = GenericWrapper(1L)
|
||||
|
||||
fun box() : String {
|
||||
val local = GenericWrapper("IL")
|
||||
val localLong = GenericWrapper(2L)
|
||||
if (global.x + local.x != "FAIL") return "FAIL 1"
|
||||
if (globalLong.x + localLong.x != 3L) return "FAIL 2"
|
||||
global.x = "O"
|
||||
local.x = "K"
|
||||
globalLong.x = 5L
|
||||
localLong.x = 6L
|
||||
if (globalLong.x + localLong.x != 11L) return "FAIL 3"
|
||||
return global.x + local.x
|
||||
}
|
||||
Reference in New Issue
Block a user