-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from JetBrains-Research/dev-litmus-tests
Add more UPUB array tests
- Loading branch information
Showing
3 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
testsuite/src/jvmMain/kotlin/org/jetbrains/litmuskt/UnsafePublicationJvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.jetbrains.litmuskt | ||
|
||
import org.jetbrains.litmuskt.autooutcomes.LitmusIOutcome | ||
import org.jetbrains.litmuskt.autooutcomes.accept | ||
import org.jetbrains.litmuskt.autooutcomes.forbid | ||
import java.util.concurrent.atomic.AtomicIntegerArray | ||
|
||
@LitmusTestContainer | ||
object UnsafePublicationJvm { | ||
val PlainAtomicIntegerArray = litmusTest({ | ||
object : LitmusIOutcome() { | ||
var arr: AtomicIntegerArray? = null | ||
} | ||
}) { | ||
thread { | ||
arr = AtomicIntegerArray(intArrayOf(1)) | ||
} | ||
thread { | ||
r1 = arr?.get(0) ?: -1 | ||
} | ||
spec { | ||
accept(1) | ||
forbid(0) | ||
accept(-1) | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
testsuite/src/nativeMain/kotlin/org/jetbrains/litmuskt/tests/UnsafePublicationNative.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.jetbrains.litmuskt.tests | ||
|
||
import org.jetbrains.litmuskt.LitmusTestContainer | ||
import org.jetbrains.litmuskt.autooutcomes.LitmusIOutcome | ||
import org.jetbrains.litmuskt.autooutcomes.accept | ||
import org.jetbrains.litmuskt.autooutcomes.interesting | ||
import org.jetbrains.litmuskt.litmusTest | ||
import kotlin.concurrent.AtomicIntArray | ||
|
||
@LitmusTestContainer | ||
object UnsafePublicationNative { | ||
|
||
@OptIn(ExperimentalStdlibApi::class) | ||
val PlainAtomicIntArray = litmusTest({ | ||
object : LitmusIOutcome() { | ||
var arr: AtomicIntArray? = null | ||
} | ||
}) { | ||
thread { | ||
arr = AtomicIntArray(1) { 1 } | ||
} | ||
thread { | ||
r1 = arr?.get(0) ?: -1 | ||
} | ||
spec { | ||
accept(1) | ||
interesting(0) | ||
accept(-1) | ||
} | ||
} | ||
} |